Re: Slow query - Mailing list pgsql-general

From Kevin Grittner
Subject Re: Slow query
Date
Msg-id 5023A06702000025000494F3@gw.wicourts.gov
Whole thread Raw
In response to Slow query  (Nicholas Wieland <ngw@nofeed.org>)
List pgsql-general
Nicholas Wieland <ngw@nofeed.org> wrote:

> Hi, I've tried to post on stackoverflow, but nobody is apparently
> able to help me.
> I'm not going to repeat everything here, there's quite some code
> in there that is nicely formatted, but if this is a problem I can
> repost it in here.

> What seems incredibly strange to me is that postgres is not using
> the indexes I've set.

Help you with what?  You're getting 14,511 rows with 54 columns each
resulting from the join of three tables in 22 ms.  What would seem
like a reasonable time to you?

As I explained on SO yesterday, it can be faster to scan the table
and build up a RAM table for fast lookup than to grovel through an
index tens of thousands of times.  If you think the index would be
faster, test that by setting enable_seqscan and enable_hashjoin to
off on your connection and try the EXPLAIN ANALYZE.  I bet you get
the plan you thought you wanted, and I bet it's slower.

-Kevin

pgsql-general by date:

Previous
From: "David Johnston"
Date:
Subject: Re: Slow query
Next
From: "Little, Douglas"
Date:
Subject: Function to dump function ddl