Обсуждение: EXPLAIN ANALYZE output

Поиск
Список
Период
Сортировка

EXPLAIN ANALYZE output

От
David Rysdam
Дата:
I'm afraid I still don't understand the output of EXPLAIN ANALYZE.  The
output I get is like this:

blah blah blah (cost=A..B blah blah) (actual time=C..D blah blah)

According to what I've been able to find:

A = predicted time to first returned row in milliseconds
B = total cost in arbitrary units
C = actual time to first returned row in milliseconds
D = actual total time in milliseconds

1) Is this correct?

I had a query that was taking a long time and I spent the last day and a
half trying to reduce D.  I probably should have been working on
reducing C, but that's neither here nor there.  Nothing I've done has
had any appreciable effect, with both C and D staying around
170000-200000 (~= 3 minutes), including dropping the sort condition.
After all this head-on-wall banging, I went back and tried doing the
query without EXPLAIN ANALYZE.  It takes under a minute, even with the
sort turned on.

2) Does EXPLAIN ANALYZE add a lot of overhead that is being measured here?

3) Even if so, why has the output of EXPLAIN ANALYZE not dropped even
though the query itself is now faster (due to something I did while
working on C/D?)?

There's been plenty of vacuuming and analyzing on these tables, so
outdated stats are not the answer.

Re: EXPLAIN ANALYZE output

От
"Joshua D. Drake"
Дата:
> There's been plenty of vacuuming and analyzing on these tables, so
> outdated stats are not the answer.

No but it could be incorrect stats do to the statistics parameter not
being set high enough.

Joshua D. Drake

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>               http://archives.postgresql.org


Re: EXPLAIN ANALYZE output

От
Tom Lane
Дата:
David Rysdam <drysdam@ll.mit.edu> writes:
> According to what I've been able to find:

> A = predicted time to first returned row in milliseconds
                                              ^^^^^^^^^^^^ arbitrary units
> B = total cost in arbitrary units
> C = actual time to first returned row in milliseconds
> D = actual total time in milliseconds

> 2) Does EXPLAIN ANALYZE add a lot of overhead that is being measured here?

Yes, its per-row overhead can be significant.  Depends on what the query
plan actually is, and how many rows go through, which you didn't say...

            regards, tom lane