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 08:31:50 -0500
Message-ID: <5163.1226583110@sss.pgh.pa.us> (raw)
In-Reply-To: <491C0962.9060405@gmail.com>
References: <491C0962.9060405@gmail.com>

Bruno Baguette <bruno.baguette@gmail.com> writes:
> I'm having a problem with this query (below) that takes betweend 14 and 
> 15 seconds to run, which is too long for the end-user.
> I've done a EXPLAIN ANALYZE (below below) but I'm having difficulties to 
> see which part of that query is taking so many times.

It's the repeatedly executed EXISTS subplan that's hurting you:

>                             SubPlan
>                               ->  Nested Loop  (cost=35.56..378.16 
> rows=2 width=0) (actual time=16.511..16.511 rows=0 loops=818)

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.

			regards, tom lane



view thread (9+ messages)  latest in thread

Message-ID: <5163.1226583110@sss.pgh.pa.us>
Permalink:  ../5163.1226583110@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5163.1226583110@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: <5163.1226583110@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