What does loop in explain analyze statement mean?
Asked Answered
S

1

15

I am profiling my query.

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)

I am not aware about what loop=1 mean in Seq Scan on student (cost=0.00..22.00 rows=1200 width=40) (actual time=0.005..0.005 rows=7 loops=1).

I have searched postgres documentation, but didn't find any good reference about loop parameter.

Thanks in advance.

Shrovetide answered 9/4, 2018 at 13:3 Comment(0)
S
18

PostgreSQL documentation does talk about this:

In some query plans, it is possible for a subplan node to be executed more than once. For example, the inner index scan will be executed once per outer row in the above nested-loop plan. In such cases, the loops value reports the total number of executions of the node, and the actual time and rows values shown are averages per-execution. This is done to make the numbers comparable with the way that the cost estimates are shown. Multiply by the loops value to get the total time actually spent in the node.

Swanskin answered 9/4, 2018 at 13:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.