30

When I run the EXPLAIN ANALYZE command on a given query, I'm having a difficult time interpreting the outputted time value. For example (actual time=8163.890..8163.893). Do the internal decimals represent repeating characters?? Sorry, this may be a noobish question, but I want to make sure I'm interpreting the results correctly.

   ->  GroupAggregate  (cost=2928781.21..2929243.02 rows=1 width=27712) (actual time=8163.890..8163.893 rows=1 loops=1)

3 Answers 3

31

actual time=8163.890..8163.893 means

Initializing that step ("startup") took 8163.890ms
Running the whole step took 8163.893ms

So in that case nearly the complete work was done in the startup phase of that step.

Edit:
The same logic is "applied" to the cost information

cost=2928781.21..2929243.02 means:

The cost to initialize this step was estimated at: 2928781.21
The cost to perform the step was estimated at: 2929243.02

(note that "cost" does not have a unit - it's an arbitrary value)

This is also explained here: http://www.postgresql.org/docs/current/static/using-explain.html

4
  • Thanks for the information and the link - I also found this document helpful, albeit somewhat outdated
    – Jmoney38
    Sep 14, 2011 at 11:59
  • Thanks for the link. The document isn't really outdated. Newer versions of PostgreSQL show more information in the plan, but the basic principles still apply.
    – user1822
    Sep 14, 2011 at 12:00
  • How do you interpret an explain analyze with this in a nested loop: (actual time=0.002..0.002 rows=0 loops=119878) ? I suppose the average per loop has rounded to zero rows which is unhelpful, but do these times really mean the execution cost is so trivial that it entirely consists of startup cost?
    – Davos
    Oct 24, 2019 at 5:08
  • @Davos You can interpret that actual time cost as "time until the first row is returned ... time until the last row is returned". When you have 0 or 1 output rows, both times should be nearly equal. For queries where every row is pretty expensive, calling the first as "startup cost" might make sense but you should interpret it as time until first row of result and it will make much more sense. Mar 18 at 9:55
21

The first number is how long it took to return the first row in that step. The second number is how long it took to return the last row.

0

Adding to above answer,

actual time=8163.890..8163.893 means 

8163.890 unit time (not necessarily in milli seconds) it took to fetch the first page from heap(table in postgress), any processing that may be required for example ordering.

In case we make select * from table_name the first page from heap will be fetched without any processing, so the first part will be 0

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.