From: Simon Riggs <simon@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Karim A Nassar <Karim.Nassar@NAU.EDU>
Cc: Stephan Szabo <sszabo@megazone.bigpanda.com>
Cc: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Cc: pgsql-performance@postgresql.org
Subject: Re: Delete query takes exorbitant amount of time
Date: Tue, 29 Mar 2005 18:17:45 +0100
Message-ID: <1112116665.11750.1017.camel@localhost.localdomain> (raw)
In-Reply-To: <21461.1112107257@sss.pgh.pa.us>
References: <Pine.SOL.4.21.0503290120550.5642-100000@coruscant.cet.nau.edu>
<1112095776.11750.958.camel@localhost.localdomain>
<21461.1112107257@sss.pgh.pa.us>
On Tue, 2005-03-29 at 09:40 -0500, Tom Lane wrote:
> Simon Riggs <simon@2ndquadrant.com> writes:
> > ...but, I see no way for OidFunctionCall8 to ever return an answer of
> > "always just 1 row, no matter how big the relation"...so tuples_fetched
> > is always proportional to the size of the relation. Are unique indexes
> > treated just as very-low-selectivity indexes?
>
> Yeah. It is not the job of amcostestimate to estimate the number of
> rows, only the index access cost. (IIRC there is someplace in the
> planner that explicitly considers unique indexes as a part of developing
> selectivity estimates ... but it's not that part.)
Well, I mention this because costsize.c:cost_index *does* calculate the
number of rows returned. If unique indexes are handled elsewhere then
this would not cause problems for them...but for LIMIT queries..?
cost_index gets the selectivity then multiplies that by number of tuples
in the relation to calc tuples_fetched, so it can use that in the
Mackert & Lohman formula. There's no consideration of the query limits.
That implies to me that LIMIT queries are not considered correctly in
the M&L formula and thus we are more likely to calculate a too-high cost
for using an index in those circumstances....and thus more likely to
SeqScan for medium sized relations?
Best Regards, Simon Riggs
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: simon@2ndquadrant.com, tgl@sss.pgh.pa.us, Karim.Nassar@NAU.EDU, sszabo@megazone.bigpanda.com, chriskl@familyhealth.com.au
Subject: Re: Delete query takes exorbitant amount of time
In-Reply-To: <1112116665.11750.1017.camel@localhost.localdomain>
* 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