解释分析语句中的循环是什么意思?

时间:2018-04-09 13:03:51

标签: sql postgresql select sql-execution-plan explain

我正在分析我的查询。

postgres=# explain analyze select * from student;
                                              QUERY PLAN
------------------------------------------------------------------------------------------------------
 Seq Scan on student  (cost=0.00..22.00 rows=1200 width=40) (actual time=0.005..0.005 rows=7 loops=1)
 Planning time: 0.035 ms
 Execution time: 0.019 ms
(3 rows)

我不知道Seq Scan on student (cost=0.00..22.00 rows=1200 width=40) (actual time=0.005..0.005 rows=7 loops=1)中的loop = 1是什么意思。

我搜索过postgres文档,但没有找到任何关于循环参数的好参考。

提前致谢。

1 个答案:

答案 0 :(得分:4)

PostgreSQL documentation确实谈到了这个:

  

在某些查询计划中,子计划节点可能会被执行多次。例如,内部索引扫描将在上述嵌套循环计划中的每个外行执行一次。在这种情况下,循环值报告节点的总执行次数,显示的实际时间和行值是每次执行的平均值。这样做是为了使数字与成本估算的显示方式相当。乘以循环值,得到节点中实际花费的总时间。

相关问题