Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nD68W-00017W-Tg for pgsql-bugs@arkaria.postgresql.org; Thu, 27 Jan 2022 14:52:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nD68U-0005rq-Rf for pgsql-bugs@arkaria.postgresql.org; Thu, 27 Jan 2022 14:52:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nD68U-0005rh-Ja for pgsql-bugs@lists.postgresql.org; Thu, 27 Jan 2022 14:52:30 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nD68Q-0004gN-9R for pgsql-bugs@postgresql.org; Thu, 27 Jan 2022 14:52:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 20REqHWV2586584; Thu, 27 Jan 2022 09:52:18 -0500 From: Tom Lane To: Christophe Courtois cc: pgsql-bugs Subject: Re: No access to TOAST tables shown in EXPLAIN ( ANALYZE, BUFFERS ) In-reply-to: References: Comments: In-reply-to Christophe Courtois message dated "Thu, 27 Jan 2022 11:11:50 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2586582.1643295137.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 27 Jan 2022 09:52:17 -0500 Message-ID: <2586583.1643295137@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Christophe Courtois writes: > I've found that EXPLAIN (ANALYZE,BUFFERS) does not show any access to th= e 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