pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim C. Nasby <jnasby@pervasive.com>
To: Brendan Duddridge <brendan@clickspace.com>
Cc: PostgreSQL Performance <pgsql-performance@postgresql.org>
Subject: Re: Assistance with optimizing query - same SQL, different category_id = Seq Scan
Date: Thu, 11 May 2006 17:08:02 -0500
Message-ID: <20060511220802.GU99570@pervasive.com> (raw)
In-Reply-To: <A8C726F2-AE42-4812-9B71-B6CFE68F18B3@clickspace.com>
References: <A8C726F2-AE42-4812-9B71-B6CFE68F18B3@clickspace.com>

On Mon, May 08, 2006 at 07:29:32PM -0600, Brendan Duddridge wrote:
> Do you have any suggestions on how I can optimize the query so both  
> versions of the query come back fast without doing a sequential scan  
> on the price table?

Well, before you do anything you should verify that an index scan in the
second case would actually be faster. Set enable_seqscan=off and check
that.

After that, you can favor an index scan by (in order of effectiveness)
increasing the correlation on the appropriate index (by clustering on
it), lowering random_page_cost, or increasing effective_cache_size.
-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461



view thread (2+ messages)

Message-ID: <20060511220802.GU99570@pervasive.com>
Permalink:  ../20060511220802.GU99570@pervasive.com/
Also on:    postgresql.org/message-id/20060511220802.GU99570@pervasive.com

 · 

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: jnasby@pervasive.com, brendan@clickspace.com
  Subject: Re: Assistance with optimizing query - same SQL, different category_id = Seq Scan
  In-Reply-To: <20060511220802.GU99570@pervasive.com>

* 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