pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedTemporary files usage in explain
4+ messages / 3 participants
[nested] [flat]
* Temporary files usage in explain
@ 2021-04-27 09:15 Matteo Bonardi <mbona92@gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Matteo Bonardi @ 2021-04-27 09:15 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi everybody,
I have a query that creates a large number of temporary files, in this
example ~ 45GB.
Looking at the query plan I can't figure out where temporary files are
being generated.
Explain plan: https://explain.depesz.com/s/BXGT
Usually I'm looking for "external merge Disk" to see temp files usage but,
in this case, the only reference to that is 299,368kB in the last but one
node of explain.
Can anyone help me understand where the 45GB are in that explain?
Thanks,
Matteo
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Temporary files usage in explain
@ 2021-04-27 09:30 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Matteo Bonardi <mbona92@gmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: Laurenz Albe @ 2021-04-27 09:30 UTC (permalink / raw)
To: Matteo Bonardi <mbona92@gmail.com>; pgsql-general@lists.postgresql.org
On Tue, 2021-04-27 at 11:15 +0200, Matteo Bonardi wrote:
> I have a query that creates a large number of temporary files, in this example ~ 45GB.
> Looking at the query plan I can't figure out where temporary files are being generated.
>
> Explain plan: https://explain.depesz.com/s/BXGT
>
> Usually I'm looking for "external merge Disk" to see temp files usage but, in this case, the only reference to that is 299,368kB in the last but one node of explain.
> Can anyone help me understand where the 45GB are in that explain?
I see at first glance: Sort Method: external merge Disk: 299,368kB
To see all, use EXPLAIN (ANALYZE, BUFFERS).
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Temporary files usage in explain
@ 2021-04-27 09:38 David Rowley <dgrowleyml@gmail.com>
parent: Matteo Bonardi <mbona92@gmail.com>
1 sibling, 1 reply; 4+ messages in thread
From: David Rowley @ 2021-04-27 09:38 UTC (permalink / raw)
To: Matteo Bonardi <mbona92@gmail.com>; +Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
On Tue, 27 Apr 2021 at 21:15, Matteo Bonardi <mbona92@gmail.com> wrote:
> Explain plan: https://explain.depesz.com/s/BXGT
>
> Usually I'm looking for "external merge Disk" to see temp files usage but, in this case, the only reference to that is 299,368kB in the last but one node of explain.
> Can anyone help me understand where the 45GB are in that explain?
If you do EXPLAIN (ANALYZE, BUFFERS) you might find that the recursive
CTE is writing the rest of them out. Something like "temp written =
", likely around 5 million or so, I imagine.
David
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Temporary files usage in explain
@ 2021-04-27 09:57 Matteo Bonardi <mbona92@gmail.com>
parent: David Rowley <dgrowleyml@gmail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Matteo Bonardi @ 2021-04-27 09:57 UTC (permalink / raw)
To: David Rowley <dgrowleyml@gmail.com>; laurenz.albe@cybertec.at, PostgreSQL General <pgsql-general@lists.postgresql.org>
Okay, I had a misconception of the buffers option.
As I reread the documentation, I realized how stupid the question was.
I confirm that with the buffers option I now see:
Buffers: shared hit=9617011 read=1328356 dirtied=793 written=397, temp
read=2996659 written=5956399
Thank you both,
Matteo
Il giorno mar 27 apr 2021 alle ore 11:38 David Rowley <dgrowleyml@gmail.com>
ha scritto:
> On Tue, 27 Apr 2021 at 21:15, Matteo Bonardi <mbona92@gmail.com> wrote:
> > Explain plan: https://explain.depesz.com/s/BXGT
> >
> > Usually I'm looking for "external merge Disk" to see temp files usage
> but, in this case, the only reference to that is 299,368kB in the last but
> one node of explain.
> > Can anyone help me understand where the 45GB are in that explain?
>
> If you do EXPLAIN (ANALYZE, BUFFERS) you might find that the recursive
> CTE is writing the rest of them out. Something like "temp written =
> ", likely around 5 million or so, I imagine.
>
> David
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2021-04-27 09:57 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 09:15 Temporary files usage in explain Matteo Bonardi <mbona92@gmail.com>
2021-04-27 09:30 ` Laurenz Albe <laurenz.albe@cybertec.at>
2021-04-27 09:38 ` David Rowley <dgrowleyml@gmail.com>
2021-04-27 09:57 ` Matteo Bonardi <mbona92@gmail.com>
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