SQL 说明使用 J2EE for Informix 的计划

SQL Explain plan using J2EE for Informix

为每个查询生成一个 SQL 解释并检索它对我来说在工作服务器上很困难。有没有一种方法可以让 java 代码执行查询并提供 SQL 解释计划,以便我可以一次获取所有数据?

注:-
我正在使用 Informix 数据库。

ifx_explain 是一个未记录的函数吗? 我在文档中找不到它 http://www.ibm.com/support/knowledgecenter/search/ifx_explain?scope=SSGU8G_12.1.0&lang=en

从 Informix 12.10.XC2 开始,您还可以使用 2 个新函数来检索查询计划:

  • ifx_explain()
  • bson_explain()

EXPLAIN 不同,这些函数从不执行查询,因此它们不会在解释输出 (EXPLAIN_STAT configuration parameter) 中提供查询统计信息部分。

这些功能没有记录,但在 How to acquire the Optimizer Explain File for a SQL statement into an Application. 中提到,现在可以通过 Internet Archive Wayback Machine 找到。

使用前面提到的 link 中提供的示例,在安装了 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

              "}