pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dan Fairs <dan.fairs@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Unexpected sequence scan
Date: Fri, 04 May 2012 10:43:19 -0400
Message-ID: <5025.1336142599@sss.pgh.pa.us> (raw)
In-Reply-To: <07F01B2A-648A-4BA7-B056-EC4EA2FFE0D0@gmail.com>
References: <07F01B2A-648A-4BA7-B056-EC4EA2FFE0D0@gmail.com>

Dan Fairs <dan.fairs@gmail.com> writes:

> I have a query which is running slowly, and the query plan shows an
unexpected sequence scan where I'd have expected the planner to use an
index. Setting enable_seqscan=off causes the planner to use the index as
expected.

That hashjoin plan doesn't look at all unreasonable to me.  The fact
that it actually comes out a lot slower than the nestloop with inner
indexscan suggests that you must be running with the large table
completely cached in RAM.  If that's the normal state of affairs for your
database, you should consider decreasing the random_page_cost setting
so that the planner will plan appropriately.

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <5025.1336142599@sss.pgh.pa.us>
Permalink:  ../5025.1336142599@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5025.1336142599@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, dan.fairs@gmail.com
  Subject: Re: Unexpected sequence scan
  In-Reply-To: <5025.1336142599@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