From: Tom Lane <tgl@sss.pgh.pa.us>
To: Avi Weinberg <AviW@gilat.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Lazy View's Column Computing
Date: Mon, 02 Aug 2021 10:23:16 -0400
Message-ID: <1626111.1627914196@sss.pgh.pa.us> (raw)
In-Reply-To: <DB9PR07MB7180094FC2775BFD3A61CC0DCBEF9@DB9PR07MB7180.eurprd07.prod.outlook.com>
References: <DB9PR07MB7180094FC2775BFD3A61CC0DCBEF9@DB9PR07MB7180.eurprd07.prod.outlook.com>
Avi Weinberg <AviW@gilat.com> writes:
> Is there a way to compute a column in a view only if it is referenced in the query? I have a view's column that its value is computed by a function. If in the query that column is not used at all, can Postgres "skip" computing it?
If the function is not volatile, and you're using a moderately recent PG
version, I'd expect the planner to do that for you.
regards, tom lane
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: tgl@sss.pgh.pa.us, AviW@gilat.com
Subject: Re: Lazy View's Column Computing
In-Reply-To: <1626111.1627914196@sss.pgh.pa.us>
References: <DB9PR07MB7180094FC2775BFD3A61CC0DCBEF9@DB9PR07MB7180.eurprd07.prod.outlook.com> <1626111.1627914196@sss.pgh.pa.us>
* 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