Re: BUG #14889: explain analyze is taking much more time than actual execution

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: mahmoud alorfaly <mahmoud(dot)alorfaly(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14889: explain analyze is taking much more time than actual execution
Date: 2017-11-06 14:43:38
Message-ID: 10068.1509979418@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> writes:
> On 6 November 2017 at 21:04, mahmoud alorfaly
> <mahmoud(dot)alorfaly(at)gmail(dot)com> wrote:
>> With EXPLAIN (ANALYZE, TIMING OFF), it is back to normal execution speed.

> Then it's just the TIMING overhead that's causing the slowdown. This
> will vary depending on how long gettimeofday() takes on your system.
> This is known to be an overhead which is one of the reasons the TIMING
> OFF option exists.

The size of the overhead in this case implies that gettimeofday() is doing
a kernel call, which I wouldn't really have expected on any modern Linux
kernel. What hardware is this on? Is there virtualization involved?

For context, on RHEL6 on run-of-the-mill server iron, I get overheads more
like this:

regression=# explain analyze select i from generate_series(1,10000000) i;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------
Function Scan on generate_series i (cost=0.00..10.00 rows=1000 width=4) (actual time=1711.319..3083.864 rows=10000000 loops=1)
Planning time: 0.078 ms
Execution time: 3636.962 ms
(3 rows)

regression=# explain (analyze, timing off) select i from generate_series(1,10000000) i;
QUERY PLAN
---------------------------------------------------------------------------------------------------------
Function Scan on generate_series i (cost=0.00..10.00 rows=1000 width=4) (actual rows=10000000 loops=1)
Planning time: 0.077 ms
Execution time: 2870.410 ms
(3 rows)

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Janes 2017-11-06 19:46:32 Re: BUG #14889: explain analyze is taking much more time than actual execution
Previous Message Alexander Korotkov 2017-11-06 11:34:24 Fwd: pg_trgm word_similarity inconsistencies or bug