From ac4913a0dd433ac1c2207014f886338f2ccd5fef Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 24 Jul 1999 23:21:14 +0000 Subject: Clean up messy clause-selectivity code in clausesel.c; repair bug identified by Hiroshi (incorrect cost attributed to OR clauses after multiple passes through set_rest_selec()). I think the code was trying to allow selectivities of OR subclauses to be passed in from outside, but noplace was actually passing any useful data, and set_rest_selec() was passing wrong data. Restructure representation of "indexqual" in IndexPath nodes so that it is the same as for indxqual in completed IndexScan nodes: namely, a toplevel list with an entry for each pass of the index scan, having sublists that are implicitly-ANDed index qual conditions for that pass. You don't want to know what the old representation was :-( Improve documentation of OR-clause indexscan functions. Remove useless 'notclause' field from RestrictInfo nodes. (This might force an initdb for anyone who has stored rules containing RestrictInfos, but I do not think that RestrictInfo ever appears in completed plans.) --- src/backend/optimizer/path/allpaths.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/backend/optimizer/path/allpaths.c') diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 220b3cd047..373d982c49 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.50 1999/07/17 20:17:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.51 1999/07/24 23:21:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -86,8 +86,8 @@ make_one_rel(Query *root, List *rels) * set_base_rel_pathlist * Finds all paths available for scanning each relation entry in * 'rels'. Sequential scan and any available indices are considered - * if possible(indices are not considered for lower nesting levels). - * All unique paths are attached to the relation's 'pathlist' field. + * if possible (indices are not considered for lower nesting levels). + * All useful paths are attached to the relation's 'pathlist' field. * * MODIFIES: rels */ @@ -98,21 +98,32 @@ set_base_rel_pathlist(Query *root, List *rels) foreach(temp, rels) { + RelOptInfo *rel = (RelOptInfo *) lfirst(temp); + List *indices = find_relation_indices(root, rel); List *sequential_scan_list; List *rel_index_scan_list; List *or_index_scan_list; - RelOptInfo *rel = (RelOptInfo *) lfirst(temp); sequential_scan_list = lcons(create_seqscan_path(rel), NIL); rel_index_scan_list = create_index_paths(root, rel, - find_relation_indices(root, rel), + indices, rel->restrictinfo, rel->joininfo); - or_index_scan_list = create_or_index_paths(root, rel, rel->restrictinfo); + /* Note: create_or_index_paths depends on create_index_paths + * to have marked OR restriction clauses with relevant indices; + * this is why it doesn't need to be given the full list of indices. + */ + or_index_scan_list = create_or_index_paths(root, rel, + rel->restrictinfo); + + /* add_pathlist will discard any paths that are dominated by + * another available path, keeping only those paths that are + * superior along at least one dimension of cost or sortedness. + */ rel->pathlist = add_pathlist(rel, sequential_scan_list, nconc(rel_index_scan_list, @@ -128,7 +139,6 @@ set_base_rel_pathlist(Query *root, List *rels) rel->size = compute_rel_size(rel); rel->width = compute_rel_width(rel); } - return; } /* -- cgit v1.2.1