mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
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.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user