From 290166f93404d8759f4bf60ef1732c8ba9a52785 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 25 Nov 2005 19:47:50 +0000 Subject: Teach planner and executor to handle ScalarArrayOpExpr as an indexable qualification when the underlying operator is indexable and useOr is true. That is, indexkey op ANY (ARRAY[...]) is effectively translated into an OR combination of one indexscan for each array element. This only works for bitmap index scans, of course, since regular indexscans no longer support OR'ing of scans. There are still some loose ends to clean up before changing 'x IN (list)' to translate as a ScalarArrayOpExpr; for instance predtest.c ought to be taught about it. But this gets the basic functionality in place. --- src/include/optimizer/paths.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/include/optimizer') diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index 4020f4bf49..eba65c699c 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -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.88 2005/10/15 02:49:45 momjian Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/paths.h,v 1.89 2005/11/25 19:47:50 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -34,6 +34,14 @@ extern void debug_print_rel(PlannerInfo *root, RelOptInfo *rel); * indxpath.c * routines to generate index paths */ +typedef enum +{ + /* Whether to use ScalarArrayOpExpr to build index qualifications */ + SAOP_FORBID, /* Do not use ScalarArrayOpExpr */ + SAOP_ALLOW, /* OK to use ScalarArrayOpExpr */ + SAOP_REQUIRE /* Require ScalarArrayOpExpr */ +} SaOpControl; + extern void create_index_paths(PlannerInfo *root, RelOptInfo *rel); extern List *generate_bitmap_or_paths(PlannerInfo *root, RelOptInfo *rel, List *clauses, List *outer_clauses, @@ -44,6 +52,7 @@ extern Path *best_inner_indexscan(PlannerInfo *root, RelOptInfo *rel, extern List *group_clauses_by_indexkey(IndexOptInfo *index, List *clauses, List *outer_clauses, Relids outer_relids, + SaOpControl saop_control, bool *found_clause); extern bool match_index_to_operand(Node *operand, int indexcol, IndexOptInfo *index); -- cgit v1.2.1