diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-01-01 21:53:49 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-01-01 21:53:49 +0000 |
commit | 29c4ad98293e3c5cb3fcdd413a3f4904efff8762 (patch) | |
tree | 4e4eeea2655e87eca4d3d0dd97f3e2b7d5f1e032 /src/backend/optimizer/path/indxpath.c | |
parent | 15faca259651c065bb20e746777f5fb9eb9d50a1 (diff) | |
download | postgresql-29c4ad98293e3c5cb3fcdd413a3f4904efff8762.tar.gz postgresql-29c4ad98293e3c5cb3fcdd413a3f4904efff8762.zip |
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.
Diffstat (limited to 'src/backend/optimizer/path/indxpath.c')
-rw-r--r-- | src/backend/optimizer/path/indxpath.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 7bb5d8993cc..456a5b9be48 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.242 2009/09/17 20:49:28 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.243 2010/01/01 21:53:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1218,7 +1218,7 @@ match_clause_to_indexcol(IndexOptInfo *index, * Clause must be a binary opclause, or possibly a ScalarArrayOpExpr * (which is always binary, by definition). Or it could be a * RowCompareExpr, which we pass off to match_rowcompare_to_indexcol(). - * Or, if the index supports it, we can handle IS NULL clauses. + * Or, if the index supports it, we can handle IS NULL/NOT NULL clauses. */ if (is_opclause(clause)) { @@ -1256,8 +1256,7 @@ match_clause_to_indexcol(IndexOptInfo *index, { NullTest *nt = (NullTest *) clause; - if (nt->nulltesttype == IS_NULL && - match_index_to_operand((Node *) nt->arg, indexcol, index)) + if (match_index_to_operand((Node *) nt->arg, indexcol, index)) return true; return false; } |