【发布时间】:2019-08-15 04:34:04
【问题描述】:
我认为在有关解释计划的 postgres 文档中发现了一个错误,并可能进行更正。
发件人:https://www.postgresql.org/docs/current/using-explain.html
Index Scan using tenk2_unique2 on tenk2 t2 (cost=0.29..7.91 rows=1 width=244) (actual time=0.021..0.022 rows=1 loops=10)
“在上面的例子中,我们总共花费了 0.220 毫秒在 tenk2 上执行索引扫描。”
文档似乎表明 Actual Total Time * Actual Loops = 花费在操作上的总时间。
但是,根据我制作的 JSON 计划:
"Plans": [
{
"Node Type": "Hash Join",
"Parent Relationship": "Outer",
"Parallel Aware": false,
"Join Type": "Inner",
"Startup Cost": 66575.34,
"Total Cost": 76861.82,
"Plan Rows": 407,
"Plan Width": 290,
"Actual Startup Time": 49962.789,
"Actual Total Time": 51206.643,
"Actual Rows": 127117,
"Actual Loops": 3,
"Output": [ ... ],
...
"Execution Time": 52677.398
(完整的计划是here。)
Actual Total Time * Actual Loops = 51 秒 * 3 = 2 分 33 秒明显超过了 Execution Time 的 52.7 秒。
我对文档的理解正确吗?
如果是这样,不应该说,“我们总共花了 0.01 毫秒在 tenk2 上执行索引扫描”吗?
【问题讨论】:
-
在这种情况下文档是正确的。您的
EXPLAIN输出不完整,因此很难判断它是否与文档相矛盾。 -
如果
Actual Total Time*Actual Loops超过Execution Time,文档如何正确? -
我不确定。这就是为什么我想看看整个计划。如果不是太多要求,以文本格式。
-
这里是:tatiyants.com/pev/#/plans/plan_1553519907593。我帖子中的操作是使用
s._fixation_key = f._fixation_key的哈希连接。 -
该链接指向我的空白页面。您可以将其添加到问题中吗?
标签: postgresql sql-execution-plan explain