| From: | "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com> | 
|---|---|
| To: | Brendan Duddridge <brendan(at)clickspace(dot)com> | 
| Cc: | PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org> | 
| Subject: | Re: Assistance with optimizing query - same SQL, different category_id = Seq Scan | 
| Date: | 2006-05-11 22:08:02 | 
| Message-ID: | 20060511220802.GU99570@pervasive.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-performance | 
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(at)pervasive(dot)com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2006-05-11 22:08:36 | Re: [HACKERS] Big IN() clauses etc : feature proposal | 
| Previous Message | Jim C. Nasby | 2006-05-11 22:05:23 | Re: Dynamically loaded C function performance |