Re: Query planning question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "John Lister" <john(dot)lister-ps(at)kickstone(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Query planning question
Date: 2009-05-11 15:06:08
Message-ID: 834.1242054368@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"John Lister" <john(dot)lister-ps(at)kickstone(dot)com> writes:
> Am I right in assuming the planner thinks a sequential scan is quicker than 10k index hits, would tweaking the costs fix this or would i be better updating the stats for the product_id and manufacturer_id fields?

AFAICT the planner did exactly the right things here. Your first
example is fetching 40 times as many rows from retailer_offer as
the second one is. If the planner had stuck with the nestloop plan,
it would've taken about 40x as long, and been significantly slower
than the hash join.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message John Lister 2009-05-11 15:21:17 Re: Query planning question
Previous Message John Lister 2009-05-11 14:43:16 Query planning question