Re: Very slow query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rory Campbell-Lange <rory(at)campbell-lange(dot)net>
Cc: Postgresql General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Very slow query
Date: 2004-05-11 11:54:34
Message-ID: 29792.1084276474@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rory Campbell-Lange <rory(at)campbell-lange(dot)net> writes:
> The following query on some small datasets takes over a second to run.
> I'd be grateful for some help in understanding the explain output, and
> to remake the code.

I think the problem is you have an unconstrained join against "people
p", which is wasting a bunch of time generating duplicate records
(and then sorting them, and then discarding them in the DISTINCT step...)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-05-11 13:22:43 Re: Trying to compute the median
Previous Message Reynir Þór Hübner 2004-05-11 10:36:35 JDBC problem