From: Gregory Stark <stark@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Guillaume Cottenceau <gc@mnc.ch>
Cc: Matthew Wakeling <matthew@flymine.org>
Cc: pgsql-performance@postgresql.org
Subject: Re: limit clause breaks query planner?
Date: Thu, 04 Sep 2008 20:54:53 +0100
Message-ID: <87wshrn0tu.fsf@oxford.xeocode.com> (raw)
In-Reply-To: <25328.1220548472@sss.pgh.pa.us>
References: <48BD33B2.D078.0028.0@rentrak.com>
<48BD33B2.D078.0028.0@rentrak.com>
<5925.1220389248@sss.pgh.pa.us>
<48BF195E.D078.0028.0@rentrak.com>
<23341.1220542340@sss.pgh.pa.us>
<alpine.DEB.1.10.0809041646340.4454@aragorn.flymine.org>
<87wshrrj10.fsf@mnc.ch>
<25328.1220548472@sss.pgh.pa.us>
Tom Lane <tgl@sss.pgh.pa.us> writes:
> Guillaume Cottenceau <gc@mnc.ch> writes:
>> It seems to me that if the correlation is 0.99[1], and you're
>> looking for less than 1% of rows, the expected rows may be at the
>> beginning or at the end of the heap?
>
> Right, but if you know the value being searched for, you could then
> estimate where it is in the table by consulting the histogram.
>
> Actually, an even easier hack (which would have the nice property of not
> needing to know the exact value being searched for), would simply use
> the existing cost estimates if the WHERE variables have low correlation
> (meaning the random-locations assumption is probably good), but apply
> some sort of penalty factor if the correlation is high.
Fwiw this will have all the same problems our existing uses of the correlation
have. That doesn't mean we shouldn't do it but I would expect it to be
improved along with the other uses when we find a better metric.
I did happen to speak to a statistician the other day and was given some terms
to google. I'll investigate and see if I get anything useful.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's RemoteDBA services!
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: stark@enterprisedb.com, tgl@sss.pgh.pa.us, gc@mnc.ch, matthew@flymine.org
Subject: Re: limit clause breaks query planner?
In-Reply-To: <87wshrn0tu.fsf@oxford.xeocode.com>
* 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