From: Tom Lane <tgl@sss.pgh.pa.us>
To: John Lister <john.lister-ps@kickstone.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Query planning question
Date: Mon, 11 May 2009 11:06:08 -0400
Message-ID: <834.1242054368@sss.pgh.pa.us> (raw)
In-Reply-To: <CDFB6E649FAB42D69FC5D4456A0F44E1@squarepi.com>
References: <CDFB6E649FAB42D69FC5D4456A0F44E1@squarepi.com>
"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 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
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-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, john.lister-ps@kickstone.com
Subject: Re: Query planning question
In-Reply-To: <834.1242054368@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