pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Craig Ringer <craig@postnewspapers.com.au>
Cc: pgsql-performance@postgresql.org
Subject: Re: Repeated execution of identical subqueries
Date: Thu, 13 Mar 2008 01:13:24 -0400
Message-ID: <7556.1205385204@sss.pgh.pa.us> (raw)
In-Reply-To: <47D8A191.6000303@postnewspapers.com.au>
References: <47D8A191.6000303@postnewspapers.com.au>

Craig Ringer <craig@postnewspapers.com.au> writes:
> Is there any way to get postgresql to detect such repeated query parts 
> and evaluate them only once?

No, not at the moment.  In principle the planner could look for such
duplicates, but it'd be wasted cycles so much of the time that I'd be
loath to do it.

There is work afoot to implement the SQL:2003 "WITH" syntax, which
I think would offer a syntactic solution to your problem.

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <7556.1205385204@sss.pgh.pa.us>
Permalink:  ../7556.1205385204@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7556.1205385204@sss.pgh.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, craig@postnewspapers.com.au
  Subject: Re: Repeated execution of identical subqueries
  In-Reply-To: <7556.1205385204@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