pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Shrirang Chitnis <Shrirang.Chitnis@hovservices.com>
Cc: Bryce Nesbitt <bryce2@obviously.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: hashed subplan 5000x slower than two sequential operations
Date: Wed, 08 Dec 2010 15:12:26 -0500
Message-ID: <20170.1291839146@sss.pgh.pa.us> (raw)
In-Reply-To: <E6DB850FDAD49A459E3C217442489C9225FB9256AB@HOV-MAIL.hovservices.com>
References: <4CFFD446.6040609@obviously.com>
	<E6DB850FDAD49A459E3C217442489C9225FB9256AB@HOV-MAIL.hovservices.com>

Shrirang Chitnis <Shrirang.Chitnis@hovservices.com> writes:
> Bryce,
> The two queries are different:

I suspect the second one is a typo and not what he really wanted.

> WHERE (contexts.parent_key = 392210
>       OR contexts.context_key IN
>          (SELECT collection_data.context_key
>          FROM collection_data
>           WHERE collection_data.collection_context_key = 392210)

The only really effective way the planner knows to optimize an
"IN (sub-SELECT)" is to turn it into a semi-join, which is not possible
here because of the unrelated OR clause.  You might consider replacing
this with a UNION of two scans of "contexts".  (And yes, I know it'd be
nicer if the planner did that for you.)

			regards, tom lane



view thread (11+ messages)  latest in thread

Message-ID: <20170.1291839146@sss.pgh.pa.us>
Permalink:  ../20170.1291839146@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20170.1291839146@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, Shrirang.Chitnis@hovservices.com, bryce2@obviously.com
  Subject: Re: hashed subplan 5000x slower than two sequential operations
  In-Reply-To: <20170.1291839146@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