Support "x IS NOT NULL" clauses as indexscan conditions. This turns out
Tom Lane <tgl@sss.pgh.pa.us>
Support "x IS NOT NULL" clauses as indexscan conditions. This turns out to be just a minor extension of the previous patch that made "x IS NULL" indexable, because we can treat the IS NOT NULL condition as if it were "x < NULL" or "x > NULL" (depending on the index's NULLS FIRST/LAST option), just like IS NULL is treated like "x = NULL". Aside from any possible usefulness in its own right, this is an important improvement for index-optimized MAX/MIN aggregates: it is now reliably possible to get a column's min or max value cheaply, even when there are a lot of nulls cluttering the interesting end of the index.
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/catalogs.sgml | modified | +2 −2 |
| doc/src/sgml/indexam.sgml | modified | +3 −2 |
| doc/src/sgml/indices.sgml | modified | +5 −6 |
| src/backend/access/common/scankey.c | modified | +3 −3 |
| src/backend/access/gist/gistget.c | modified | +14 −8 |
| src/backend/access/gist/gistscan.c | modified | +8 −5 |
| src/backend/access/nbtree/nbtutils.c | modified | +109 −35 |
| src/backend/executor/nodeIndexscan.c | modified | +23 −6 |
| src/backend/optimizer/path/indxpath.c | modified | +3 −4 |
| src/backend/optimizer/plan/createplan.c | modified | +8 −4 |
| src/backend/optimizer/plan/planagg.c | modified | +24 −14 |
| src/backend/utils/adt/selfuncs.c | modified | +15 −13 |
| src/include/access/skey.h | modified | +14 −11 |
| src/include/catalog/pg_am.h | modified | +2 −2 |
| src/include/nodes/relation.h | modified | +2 −2 |
| src/include/optimizer/planmain.h | modified | +2 −1 |
| src/test/regress/expected/create_index.out | modified | +49 −1 |
| src/test/regress/sql/create_index.sql | modified | +9 −1 |