簡體   English   中英

使用Eclipse JDBC將Postgres查詢計划轉換為xml並存儲在文件中

[英]Converting Postgres Query Plan into xml and store in file using Eclipse JDBC

按照標題,我目前在eclipse上使用JDBC連接到我的PostgreSQL。

我一直在運行EXPLAIN ANALYZE語句來從postgres本身檢索查詢計划。 但是,是否可以將這些查詢計划存儲在類似於樹的結構中? 例如主分支和子分支等。我在某處讀到,最好先將其存儲到xml文檔中,然后從那里進行操作。

我是否可以使用Java中的API來實現這一目標? 謝謝!

嘗試使用format xml例如

t=# explain (analyze, format xml) select * from pg_database join pg_class on true;
                           QUERY PLAN
----------------------------------------------------------------
 <explain xmlns="http://www.postgresql.org/2009/explain">      +
   <Query>                                                     +
     <Plan>                                                    +
       <Node-Type>Nested Loop</Node-Type>                      +
       <Join-Type>Inner</Join-Type>                            +
       <Startup-Cost>0.00</Startup-Cost>                       +
       <Total-Cost>23.66</Total-Cost>                          +
       <Plan-Rows>722</Plan-Rows>                              +
       <Plan-Width>457</Plan-Width>                            +
       <Actual-Startup-Time>0.026</Actual-Startup-Time>        +
       <Actual-Total-Time>3.275</Actual-Total-Time>            +
       <Actual-Rows>5236</Actual-Rows>                         +
       <Actual-Loops>1</Actual-Loops>                          +
       <Plans>                                                 +
         <Plan>                                                +
           <Node-Type>Seq Scan</Node-Type>                     +
           <Parent-Relationship>Outer</Parent-Relationship>    +
     ...and so on

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM