在工作服务器上,我很难为每个查询生成SQL解释并检索它。有没有办法可以让java代码执行查询,并提供SQL解释计划,以便我可以一次获取所有数据?
注意: -
我正在使用Informix数据库。
答案 0 :(得分:0)
ifx_explain是一个未记录的函数吗? 我在文档http://www.ibm.com/support/knowledgecenter/search/ifx_explain?scope=SSGU8G_12.1.0&lang=en
中找不到它答案 1 :(得分:0)
从Informix 12.10.XC2开始,您还可以使用2个新功能来检索查询计划:
与EXPLAIN
不同,这些函数从不执行查询,因此它们在说明输出(EXPLAIN_STAT configuration parameter)中不提供“查询统计信息”部分。
这些功能没有记录,但在How to acquire the Optimizer Explain File for a SQL statement into an Application.中已有提及,现在可以通过Internet Archive Wayback Machine找到。
使用前面提到的链接中提供的示例,在安装了Informix的本地虚拟机中,我得到以下信息:
execute function ifx_explain( 'select * from systables' );
(expression)
QUERY: (OPTIMIZATION TIMESTAMP: 07-05-2019 16:57:42)
------
select * from systables
Estimated Cost: 11
Estimated # of Rows Returned: 87
1) informix.systables: SEQUENTIAL SCAN
--
-- bson_explain returns a BSON column, so cast it to a JSON, for human readability
--
SELECT bson_explain( 'select * from systables where tabid=99' )::JSON from sysmaster:sysdual
(expression) {"version":1,"explain":"
QUERY: (OPTIMIZATION TIMESTAMP: 07-05-2019 17:02:00)
------
select * from systables where tabid=99
Estimated Cost: 1
Estimated # of Rows Returned: 1
1) informix.systables: INDEX PATH
(1) Index Name: informix.tabid
Index Keys: tabid
Lower Index Filter: informix.systables.tabid = 99
"}