Re: Query planning question - Mailing list pgsql-sql

From Tom Lane
Subject Re: Query planning question
Date
Msg-id 834.1242054368@sss.pgh.pa.us
Whole thread Raw
In response to Query planning question  ("John Lister" <john.lister-ps@kickstone.com>)
List pgsql-sql
"John Lister" <john.lister-ps@kickstone.com> writes:
> Am I right in assuming the planner thinks a sequential scan is quicker than 10k index hits, would tweaking the costs
fixthis 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


pgsql-sql by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Distinct oddity
Next
From: "John Lister"
Date:
Subject: Re: Query planning question