3

I have a question regarding the meaning of actual time in an execution plan.

I read the following things but they seem to be contradictory:

  1. The first value is the time to retrieve the first line and the seconds value is the time to retrieve the last line.
  2. When I want to know which operation takes a long time, I take the second value of actual time of the outer operation and the second value of actual time of the inner operation.

Example:

EXPLAIN (ANALYZE) SELECT * FROM foo ORDER BY c1;

QUERY PLAN
­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­-> Sort(cost=172682.84..175182.84 rows=1000000 width=37)(actual time=612.793..729.135 rows=1000000 loops=1)
   Sort Key: c1
   Sort Method: external sort  Disk: 45952kB
   -> Seq Scan on foo  (cost=0.00..18334.00 rows=1000000 width=37)(actual time=0.017..111.068 rows=1000000 loops=1)
Total runtime: 772.685 ms

According to the point 1, the sort operations takes (729 - 612) 117ms.

According to the point 2, the sort operation takes 618 ms.

Can anybody explain to me what I'm missing here?

1 Answer 1

4

Your assumption 1) is wrong.

The first time is the time it takes to initialize the step. The second time is the total time the step took (including child steps).

So the total time for the sort step is 729ms - 111ms of that were spent retrieving the data through a Seq Scan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.