Re: No access to TOAST tables shown in EXPLAIN ( ANALYZE, BUFFERS )

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christophe Courtois <christophe(dot)courtois(at)dalibo(dot)com>
Cc: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: No access to TOAST tables shown in EXPLAIN ( ANALYZE, BUFFERS )
Date: 2022-01-27 14:52:17
Message-ID: 2586583.1643295137@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-docs

Christophe Courtois <christophe(dot)courtois(at)dalibo(dot)com> writes:
> I've found that EXPLAIN (ANALYZE,BUFFERS) does not show any access to the TOAST tables when a toasted column is only SELECTed and not used in any way in the query.

This is probably because of the documented, long-standing behavior that
EXPLAIN does not convert the query's output rows to text, nor send them
to the client. If the datatype output functions aren't called, the
output datums won't get detoasted either.

I don't see anything here we want to change. The argument for not
bothering to model output costs has always been that they'd be the
same for every possible query plan, and I think that that applies to
detoasting costs as much as the actual output conversions. Moreover,
if we're not sending data to the client, the skipped network I/O could
easily represent a larger cost than anything else --- but there's no
reasonable way to account for that.

If you do care about those costs, a possible answer is to run
auto_explain, allowing you to capture data behind-the-scenes for
queries that really are sending data to clients.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2022-01-27 20:57:28 BUG #17384: ERROR: missing chunk number 0 for toast value 152073604 in pg_toast_2619
Previous Message Bharath Rupireddy 2022-01-27 14:16:55 Re: BUG #17375: RECOVERY TARGET TIME RESTORE IS FAILING TO START SERVER

Browse pgsql-docs by date

  From Date Subject
Next Message PG Doc comments form 2022-01-27 15:43:00 Datetime formatting
Previous Message Christophe Courtois 2022-01-27 10:11:50 No access to TOAST tables shown in EXPLAIN ( ANALYZE, BUFFERS )