Re: EXPLAIN ANALYZE does not return accurate execution times

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Mark Mizzi <mizzimark2001(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: EXPLAIN ANALYZE does not return accurate execution times
Date: 2022-10-27 13:35:10
Message-ID: 20221027133510.fntozs3aubhs6olh@jrouhaud
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

On Thu, Oct 27, 2022 at 03:28:14PM +0200, Mark Mizzi wrote:
>
> EXPLAIN ANALYZE SELECT * FROM unary;
>
> I get the following result:
>
> Seq Scan on unary (cost=0.00..1637.01 rows=100001 width=18) (actual
> time=0.009..6.667 rows=100001 loops=1)
> Planning Time: 0.105 ms
> Execution Time: 8.565 ms
>
> [...]
>
> sudo -u postgres psql -c "SELECT * FROM unary" -o /dev/null 0.01s user
> 0.01s system 0% cpu 16.912 total
>
> I am running Postgres 14 (installed via apt) on Ubuntu 22.04. All settings
> are default.
> The machine is a Dell Vostro 7500.
>
> All commands are being run locally, so I don't think this is a network
> bandwidth issue. What's going on?

EXPLAIN ANALYZE doesn't output the tuples, so it hides that part of the query
processing. It's usually not a problem, at least if you want to identify non
optimal queries, but here you probably have the perfect scenario to notice the
difference.

You could try to use something like "SELECT COUNT(*) FROM unary", the timings
should be closer and the query would still scan all the lines.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2022-10-27 13:43:44 Re: EXPLAIN ANALYZE does not return accurate execution times
Previous Message Mark Mizzi 2022-10-27 13:28:14 EXPLAIN ANALYZE does not return accurate execution times