From: Julien Rouhaud <rjuju123@gmail.com>
To: Mark Mizzi <mizzimark2001@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: EXPLAIN ANALYZE does not return accurate execution times
Date: Thu, 27 Oct 2022 21:35:10 +0800
Message-ID: <20221027133510.fntozs3aubhs6olh@jrouhaud> (raw)
In-Reply-To: <CANQK6i8FeAXhTa9F6p8JKoVRHene5da7vLjrA3+P=A2XR6J2pQ@mail.gmail.com>
References: <CANQK6i8FeAXhTa9F6p8JKoVRHene5da7vLjrA3+P=A2XR6J2pQ@mail.gmail.com>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: rjuju123@gmail.com, mizzimark2001@gmail.com
Subject: Re: EXPLAIN ANALYZE does not return accurate execution times
In-Reply-To: <20221027133510.fntozs3aubhs6olh@jrouhaud>
References: <CANQK6i8FeAXhTa9F6p8JKoVRHene5da7vLjrA3+P=A2XR6J2pQ@mail.gmail.com> <20221027133510.fntozs3aubhs6olh@jrouhaud>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox