Re: Slow query

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Nicholas Wieland" <ngw(at)nofeed(dot)org>,<pgsql-general(at)postgresql(dot)org>
Subject: Re: Slow query
Date: 2012-08-09 16:35:03
Message-ID: 5023A06702000025000494F3@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Nicholas Wieland <ngw(at)nofeed(dot)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

In response to

  • Slow query at 2012-08-09 15:47:19 from Nicholas Wieland

Browse pgsql-general by date

  From Date Subject
Next Message Little, Douglas 2012-08-09 17:06:24 Function to dump function ddl
Previous Message David Johnston 2012-08-09 16:11:15 Re: Slow query