Avoid scanning nulls at the beginning of a btree index scan.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 2 Nov 2011 23:35:48 +0000 (19:35 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 2 Nov 2011 23:35:48 +0000 (19:35 -0400)
commit1a77f8b63d159b88ceb6245fcb5e81a7f9ac9a22
tree398756af0dfab7b101bef1738aab76904af47d11
parent882368e854b6f094f94aca292f390bbd9f44359b
Avoid scanning nulls at the beginning of a btree index scan.

If we have an inequality key that constrains the other end of the index,
it doesn't directly help us in doing the initial positioning ... but it
does imply a NOT NULL constraint on the index column.  If the index stores
nulls at this end, we can use the implied NOT NULL condition for initial
positioning, just as if it had been stated explicitly.  This avoids wasting
time when there are a lot of nulls in the column.  This is the reverse of
the examples given in bugs #6278 and #6283, which were about failing to
stop early when we encounter nulls at the end of the indexscan.
src/backend/access/nbtree/nbtsearch.c