pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Quick question
Date: Mon, 08 Sep 2003 23:14:29 -0400
Message-ID: <19153.1063077269@sss.pgh.pa.us> (raw)
In-Reply-To: <200309082002.18830.josh@agliodbs.com>
References: <200309082002.18830.josh@agliodbs.com>

Josh Berkus <josh@agliodbs.com> writes:
> Back in the 7.0 days, 
> WHERE EXISTS (SELECT * FROM a WHERE condition)
> was significantly slower on broad tables than
> WHERE EXISTS (SELECT small_col FROM a WHERE condition)
> Is this still true, or something that's been fixed in the last 3 versions?  

It's still true that all the sub-select's output columns will be
evaluated.  Given that this happens for at most one row, I'm not sure
how significant the hit really is.  But it's annoying, seeing that the
outer EXISTS doesn't care what the column values are.

> Joe Celko is making fun of me because Oracle doesn't have this performance 
> issue.

Perhaps Joe can tell us exactly which part of SQL92 says it's okay not
to evaluate side-effect-producing functions in the targetlist of an
EXISTS subselect.

I would like to make the system change the targetlist to just "SELECT 1"
in an EXISTS subquery.  But I'm slightly concerned about changing the
semantics of existing queries.  If someone can produce proof that this
is allowed (or even better, required) by the SQL spec, it'd be easier...

			regards, tom lane



view thread (2+ messages)

Message-ID: <19153.1063077269@sss.pgh.pa.us>
Permalink:  ../19153.1063077269@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/19153.1063077269@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 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-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com
  Subject: Re: Quick question
  In-Reply-To: <19153.1063077269@sss.pgh.pa.us>
  References: <200309082002.18830.josh@agliodbs.com> <19153.1063077269@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