Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7c579fa

Browse files
committed
Further work on making use of new statistics in planner. Adjust APIs
of costsize.c routines to pass Query root, so that costsize can figure more things out by itself and not be so dependent on its callers to tell it everything it needs to know. Use selectivity of hash or merge clause to estimate number of tuples processed internally in these joins (this is more useful than it would've been before, since eqjoinsel is somewhat more accurate than before).
1 parent 28d2420 commit 7c579fa

20 files changed

+337
-195
lines changed

src/backend/nodes/copyfuncs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.142 2001/05/20 20:28:17 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.143 2001/06/05 05:26:03 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -1361,9 +1361,10 @@ _copyRestrictInfo(RestrictInfo *from)
13611361
* copy remainder of node
13621362
*/
13631363
Node_Copy(from, newnode, clause);
1364-
newnode->eval_cost = from->eval_cost;
13651364
newnode->ispusheddown = from->ispusheddown;
13661365
Node_Copy(from, newnode, subclauseindices);
1366+
newnode->eval_cost = from->eval_cost;
1367+
newnode->this_selec = from->this_selec;
13671368
newnode->mergejoinoperator = from->mergejoinoperator;
13681369
newnode->left_sortop = from->left_sortop;
13691370
newnode->right_sortop = from->right_sortop;

src/backend/nodes/equalfuncs.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Portions Copyright (c) 1994, Regents of the University of California
2121
*
2222
* IDENTIFICATION
23-
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.90 2001/05/20 20:28:18 tgl Exp $
23+
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.91 2001/06/05 05:26:03 tgl Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -514,14 +514,14 @@ _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b)
514514
{
515515
if (!equal(a->clause, b->clause))
516516
return false;
517-
518-
/*
519-
* ignore eval_cost, left/right_pathkey, and left/right_bucketsize,
520-
* since they may not be set yet, and should be derivable from the
521-
* clause anyway
522-
*/
523517
if (a->ispusheddown != b->ispusheddown)
524518
return false;
519+
/*
520+
* We ignore eval_cost, this_selec, left/right_pathkey, and
521+
* left/right_bucketsize, since they may not be set yet, and should be
522+
* derivable from the clause anyway. Probably it's not really necessary
523+
* to compare any of these remaining fields ...
524+
*/
525525
if (!equal(a->subclauseindices, b->subclauseindices))
526526
return false;
527527
if (a->mergejoinoperator != b->mergejoinoperator)

src/backend/nodes/readfuncs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.109 2001/05/20 20:28:18 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.110 2001/06/05 05:26:04 tgl Exp $
1212
*
1313
* NOTES
1414
* Most of the read functions for plan nodes are tested. (In fact, they
@@ -1792,6 +1792,8 @@ _readRestrictInfo(void)
17921792

17931793
/* eval_cost is not part of saved representation; compute on first use */
17941794
local_node->eval_cost = -1;
1795+
/* ditto for this_selec */
1796+
local_node->this_selec = -1;
17951797
/* ditto for cached pathkeys and bucketsize */
17961798
local_node->left_pathkey = NIL;
17971799
local_node->right_pathkey = NIL;

src/backend/optimizer/path/allpaths.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.74 2001/05/20 20:28:18 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.75 2001/06/05 05:26:04 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -223,7 +223,7 @@ set_plain_rel_pathlist(Query *root, RelOptInfo *rel, RangeTblEntry *rte)
223223
*/
224224

225225
/* Consider sequential scan */
226-
add_path(rel, create_seqscan_path(rel));
226+
add_path(rel, create_seqscan_path(root, rel));
227227

228228
/* Consider TID scans */
229229
create_tidscan_paths(root, rel);

src/backend/optimizer/path/clausesel.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.44 2001/05/20 20:28:18 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.45 2001/06/05 05:26:04 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -48,9 +48,6 @@ typedef struct RangeQueryClause
4848

4949
static void addRangeClause(RangeQueryClause **rqlist, Node *clause,
5050
bool varonleft, bool isLTsel, Selectivity s2);
51-
static Selectivity clause_selectivity(Query *root,
52-
Node *clause,
53-
int varRelid);
5451

5552

5653
/****************************************************************************
@@ -364,7 +361,7 @@ addRangeClause(RangeQueryClause **rqlist, Node *clause,
364361
* When varRelid is 0, all variables are treated as variables. This
365362
* is appropriate for ordinary join clauses and restriction clauses.
366363
*/
367-
static Selectivity
364+
Selectivity
368365
clause_selectivity(Query *root,
369366
Node *clause,
370367
int varRelid)

0 commit comments

Comments
 (0)