Commit 2f121062 authored by Tom Lane's avatar Tom Lane

Separate predicate-testing code out of indxpath.c, making it a module

in its own right.  As proposed by Simon Riggs, but with some editorializing
of my own.
parent 111e29ef
This diff is collapsed.
......@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.191 2005/06/05 22:32:55 tgl Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.192 2005/06/10 22:25:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -22,9 +22,9 @@
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/paths.h"
#include "optimizer/plancat.h"
#include "optimizer/planmain.h"
#include "optimizer/predtest.h"
#include "optimizer/restrictinfo.h"
#include "optimizer/tlist.h"
#include "optimizer/var.h"
......@@ -782,8 +782,8 @@ create_indexscan_plan(PlannerInfo *root,
* spot duplicate RestrictInfos, so we try that first. In some situations
* (particularly with OR'd index conditions) we may have scan_clauses
* that are not equal to, but are logically implied by, the index quals;
* so we also try a pred_test() check to see if we can discard quals
* that way.
* so we also try a predicate_implied_by() check to see if we can discard
* quals that way.
*
* While at it, we strip off the RestrictInfos to produce a list of
* plain expressions.
......@@ -796,7 +796,8 @@ create_indexscan_plan(PlannerInfo *root,
Assert(IsA(rinfo, RestrictInfo));
if (list_member_ptr(nonlossy_indexquals, rinfo))
continue;
if (pred_test(list_make1(rinfo->clause), nonlossy_indexquals))
if (predicate_implied_by(list_make1(rinfo->clause),
nonlossy_indexquals))
continue;
qpqual = lappend(qpqual, rinfo->clause);
}
......@@ -878,7 +879,7 @@ create_bitmap_scan_plan(PlannerInfo *root,
* clauses, so we try that first. In some situations (particularly with
* OR'd index conditions) we may have scan_clauses that are not equal to,
* but are logically implied by, the index quals; so we also try a
* pred_test() check to see if we can discard quals that way.
* predicate_implied_by() check to see if we can discard quals that way.
*/
qpqual = NIL;
foreach(l, scan_clauses)
......@@ -887,7 +888,8 @@ create_bitmap_scan_plan(PlannerInfo *root,
if (list_member(indexquals, clause))
continue;
if (pred_test(list_make1(clause), indexquals))
if (predicate_implied_by(list_make1(clause),
indexquals))
continue;
qpqual = lappend(qpqual, clause);
}
......
......@@ -4,7 +4,7 @@
# Makefile for optimizer/util
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/optimizer/util/Makefile,v 1.15 2003/11/29 19:51:51 pgsql Exp $
# $PostgreSQL: pgsql/src/backend/optimizer/util/Makefile,v 1.16 2005/06/10 22:25:36 tgl Exp $
#
#-------------------------------------------------------------------------
......@@ -12,8 +12,8 @@ subdir = src/backend/optimizer/util
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
OBJS = restrictinfo.o clauses.o plancat.o \
joininfo.o pathnode.o relnode.o tlist.o var.o
OBJS = clauses.o joininfo.o pathnode.o plancat.o predtest.o \
relnode.o restrictinfo.o tlist.o var.o
all: SUBSYS.o
......
This diff is collapsed.
......@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.180 2005/06/05 22:32:57 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.181 2005/06/10 22:25:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -4221,12 +4221,11 @@ genericcostestimate(PlannerInfo *root,
* of partial redundancy (such as "x < 4" from the qual and "x < 5"
* from the predicate) will be recognized and handled correctly by
* clauselist_selectivity(). This assumption is somewhat fragile,
* since it depends on pred_test() and clauselist_selectivity() having
* similar capabilities, and there are certainly many cases where we
* will end up with a too-low selectivity estimate. This will bias
* the system in favor of using partial indexes where possible, which
* is not necessarily a bad thing. But it'd be nice to do better
* someday.
* since it depends on predicate_implied_by() and clauselist_selectivity()
* having similar capabilities, and there are certainly many cases where
* we will end up with a too-low selectivity estimate. This will bias the
* system in favor of using partial indexes where possible, which is not
* necessarily a bad thing. But it'd be nice to do better someday.
*
* Note that index->indpred and indexQuals are both in implicit-AND form,
* so ANDing them together just takes merging the lists. However,
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/optimizer/paths.h,v 1.84 2005/06/05 22:32:58 tgl Exp $
* $PostgreSQL: pgsql/src/include/optimizer/paths.h,v 1.85 2005/06/10 22:25:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -49,7 +49,6 @@ extern bool match_index_to_operand(Node *operand, int indexcol,
extern List *expand_indexqual_conditions(IndexOptInfo *index,
List *clausegroups);
extern void check_partial_indexes(PlannerInfo *root, RelOptInfo *rel);
extern bool pred_test(List *predicate_list, List *restrictinfo_list);
extern List *flatten_clausegroups_list(List *clausegroups);
/*
......
/*-------------------------------------------------------------------------
*
* predtest.h
* prototypes for predtest.c
*
*
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/optimizer/predtest.h,v 1.1 2005/06/10 22:25:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PREDTEST_H
#define PREDTEST_H
#include "nodes/primnodes.h"
extern bool predicate_implied_by(List *predicate_list,
List *restrictinfo_list);
#endif /* PREDTEST_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment