pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruno Baguette <bruno.baguette@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Slow SQL query (14-15 seconds)
Date: Thu, 13 Nov 2008 09:30:08 -0500
Message-ID: <14560.1226586608@sss.pgh.pa.us> (raw)
In-Reply-To: <491C377E.3070904@gmail.com>
References: <491C0962.9060405@gmail.com>
	<5163.1226583110@sss.pgh.pa.us>
	<491C377E.3070904@gmail.com>

Bruno Baguette <bruno.baguette@gmail.com> writes:
> Le 13/11/08 14:31, Tom Lane a écrit :
>> 16.511 * 818 = 13505.998, so this is all but about 100 msec of the
>> runtime.  Can't tell if there's any easy way to improve it.  In
>> pre-8.4 releases trying to convert the EXISTS into an IN might help.

> Can you explain why a IN is fastest than an EXISTS subquery ?

The planner is smarter about IN than EXISTS --- it can usually convert
the former into a join plan instead of a subplan.  (This situation will
improve in 8.4.)

> Do you think I can improve again the performance of that query ?

You've still got a subplan in there, not quite sure why.  Anyway,
increasing work_mem might get it to change to a hashed subplan,
which'd likely be faster.

			regards, tom lane



view thread (9+ messages)  latest in thread

Message-ID: <14560.1226586608@sss.pgh.pa.us>
Permalink:  ../14560.1226586608@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14560.1226586608@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, bruno.baguette@gmail.com
  Subject: Re: Slow SQL query (14-15 seconds)
  In-Reply-To: <14560.1226586608@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