Re: Very slow query - Mailing list pgsql-general

From Tom Lane
Subject Re: Very slow query
Date
Msg-id 29792.1084276474@sss.pgh.pa.us
Whole thread Raw
In response to Very slow query  (Rory Campbell-Lange <rory@campbell-lange.net>)
List pgsql-general
Rory Campbell-Lange <rory@campbell-lange.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

pgsql-general by date:

Previous
From: Reynir Þór Hübner
Date:
Subject: JDBC problem
Next
From: Tom Lane
Date:
Subject: Re: Trying to compute the median