=?iso-2022-jp?B?GyRCMEJAPiEhRD5MaRsoQg==?= <anzai-naoya(at)mxu(dot)nes(dot)nec(dot)co(dot)jp> writes:
> I have checked latest source code.
> But, backward scan doesn't work correctly...
[ pokes at that... ] Hmm, the patches I applied a couple days ago
assumed that we are stepping forward or back from a place where the
WHERE clauses are satisfied. But in this example, the system just
applies _bt_endpoint to descend to the right-hand end of the index,
since there is no upper-bound qual with which to do anything different.
So we start from a place where the clauses aren't satisfied. That also
means that we haven't really fixed the original performance complaint:
there could be lots of nulls to be stepped over before we reach the
first matching row.
I think that the right fix for this is probably to make
_bt_preprocess_keys explicitly generate the "id is not null" qual that's
implied by "id > 0", so that it will have what amounts to a range
condition on the index contents (since for NULLS LAST, "id is not null"
amounts to "id is less than null", as it were). Then, instead of applying
_bt_endpoint, it will use the less-than key to descend the btree to the
last non-null entry, and we'll be good for both correctness and
I don't see any big problem in doing this in HEAD, but it's getting past
what seems like a sane back-patch. So probably we should revert the
back-branch versions of the prior patch, and just say that the
performance problem is only going to be addressed in HEAD.
regards, tom lane
In response to
pgsql-bugs by date
|Next:||From: Archana Sachin Ghag||Date: 2011-11-03 11:32:52|
|Subject: Issue with passing NULL for function parameter|
|Previous:||From: 安西 直也||Date: 2011-11-02 09:39:48|
|Subject: Re: BUG #6283: About the behavior of indexscan in case there are some NULL values.|