From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Alexander Korotkov <aekorotkov(at)gmail(dot)com> |
Cc: | Vasilis Ventirozos <v(dot)ventirozos(at)gmail(dot)com>, postgres performance list <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Index usage for tstzrange? |
Date: | 2013-03-22 21:53:29 |
Message-ID: | 514CD2D9.4080008@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On 21.03.2013 17:55, Alexander Korotkov wrote:
> On Thu, Mar 21, 2013 at 12:52 PM, Heikki Linnakangas<
>> The immediate fix is attached, but this made me realize that rangesel() is
>> still missing estimation for the "element<@ range" operator. It shouldn't
>> be hard to implement, I'm pretty sure we have all the statistics we need
>> for that.
>
> Probably we could even call existing scalarltsel and scalargtsel for this
> case.
I came up with the attached. I didn't quite use scalarltsel, but I used
the scalarineqsel function, which contains the "guts" of scalarltsel and
scalargtsel.
One thing I wasn't quite sure of (from the patch):
> /*
> * We use the data type's default < operator. This is bogus, if the range
> * type's rngsubopc operator class is different. In practice, that ought
> * to be rare. It would also be bogus to use the < operator from the
> * rngsubopc operator class, because the statistics are collected using
> * using the default operator class, anyway.
> *
> * For the same reason, use the default collation. The statistics are
> * collected with the default collation.
> */
Does that make sense? The other option would be to use the < operator
from the rngsubopc op class, even though the scalar statistics are
collected with the default b-tree < operator. As long as the two sort
roughly the same way, you get reasonable results either way. Yet another
option would be to use histogram_selectivity() instead of
ineq_histogram_selectivity(), if the range's rngsubopc opclass isn't the
type's default opclass. histogram_selectivity() works with any operator
regardless of the sort ordering, basically using the histogram values
merely as a sample, rather than as a histogram. But I'm reluctant to
make this any more complicated, as using a non-default opclass for the
range type is rare.
- Heikki
Attachment | Content-Type | Size |
---|---|---|
estimate-elem-contained-by-1.patch | text/x-diff | 6.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Cindy Makarowsky | 2013-03-22 22:20:15 | Re: Performance of query |
Previous Message | Josh Berkus | 2013-03-22 21:13:50 | Re: Performance of query |