gpt4 book ai didi

java - 使用 Eclipse JDBC 将 Postgres 查询计划转换为 xml 并存储在文件中

转载 作者:行者123 更新时间:2023-12-02 12:06:44 25 4
gpt4 key购买 nike

根据标题,我目前在 eclipse 上使用 JDBC 连接到我的 PostgreSQL。

我一直在运行 EXPLAIN ANALYZE 语句来从 postgres 本身检索查询计划。但是,是否可以将这些查询计划存储在类似于树的结构中?例如主分支和子分支等。我在某处读到,最好先将其存储到 xml 文档中并从那里对其进行操作。

Java 中有 API 可以帮助我实现此目的吗?谢谢!

最佳答案

尝试使用格式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

关于java - 使用 Eclipse JDBC 将 Postgres 查询计划转换为 xml 并存储在文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46855067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com