Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
8f0a9e85
Commit
8f0a9e85
authored
Mar 01, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Second thoughts dept: arrange to cache mergejoin scan selectivity
in RestrictInfo nodes, instead of recomputing on every use.
parent
f8c10952
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
13 deletions
+34
-13
src/backend/nodes/copyfuncs.c
src/backend/nodes/copyfuncs.c
+3
-1
src/backend/nodes/readfuncs.c
src/backend/nodes/readfuncs.c
+4
-2
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/costsize.c
+16
-7
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/initsplan.c
+3
-1
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/prep/prepunion.c
+3
-1
src/include/nodes/relation.h
src/include/nodes/relation.h
+5
-1
No files found.
src/backend/nodes/copyfuncs.c
View file @
8f0a9e85
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.16
3 2002/02/26 22:47:05
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.16
4 2002/03/01 06:01:18
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -1406,6 +1406,8 @@ _copyRestrictInfo(RestrictInfo *from)
...
@@ -1406,6 +1406,8 @@ _copyRestrictInfo(RestrictInfo *from)
*/
*/
newnode
->
left_pathkey
=
NIL
;
newnode
->
left_pathkey
=
NIL
;
newnode
->
right_pathkey
=
NIL
;
newnode
->
right_pathkey
=
NIL
;
newnode
->
left_mergescansel
=
from
->
left_mergescansel
;
newnode
->
right_mergescansel
=
from
->
right_mergescansel
;
newnode
->
hashjoinoperator
=
from
->
hashjoinoperator
;
newnode
->
hashjoinoperator
=
from
->
hashjoinoperator
;
newnode
->
left_bucketsize
=
from
->
left_bucketsize
;
newnode
->
left_bucketsize
=
from
->
left_bucketsize
;
newnode
->
right_bucketsize
=
from
->
right_bucketsize
;
newnode
->
right_bucketsize
=
from
->
right_bucketsize
;
...
...
src/backend/nodes/readfuncs.c
View file @
8f0a9e85
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.11
4 2002/02/26 22:47:07
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.11
5 2002/03/01 06:01:18
tgl Exp $
*
*
* NOTES
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
* Most of the read functions for plan nodes are tested. (In fact, they
...
@@ -1846,9 +1846,11 @@ _readRestrictInfo(void)
...
@@ -1846,9 +1846,11 @@ _readRestrictInfo(void)
local_node
->
eval_cost
=
-
1
;
local_node
->
eval_cost
=
-
1
;
/* ditto for this_selec */
/* ditto for this_selec */
local_node
->
this_selec
=
-
1
;
local_node
->
this_selec
=
-
1
;
/* ditto for cached pathkeys
and
bucketsize */
/* ditto for cached pathkeys
, selectivity,
bucketsize */
local_node
->
left_pathkey
=
NIL
;
local_node
->
left_pathkey
=
NIL
;
local_node
->
right_pathkey
=
NIL
;
local_node
->
right_pathkey
=
NIL
;
local_node
->
left_mergescansel
=
-
1
;
local_node
->
right_mergescansel
=
-
1
;
local_node
->
left_bucketsize
=
-
1
;
local_node
->
left_bucketsize
=
-
1
;
local_node
->
right_bucketsize
=
-
1
;
local_node
->
right_bucketsize
=
-
1
;
...
...
src/backend/optimizer/path/costsize.c
View file @
8f0a9e85
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.8
0 2002/03/01 04:09:24
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.8
1 2002/03/01 06:01:19
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -566,6 +566,7 @@ cost_mergejoin(Path *path, Query *root,
...
@@ -566,6 +566,7 @@ cost_mergejoin(Path *path, Query *root,
Cost
startup_cost
=
0
;
Cost
startup_cost
=
0
;
Cost
run_cost
=
0
;
Cost
run_cost
=
0
;
Cost
cpu_per_tuple
;
Cost
cpu_per_tuple
;
RestrictInfo
*
firstclause
;
double
outer_rows
,
double
outer_rows
,
inner_rows
;
inner_rows
;
double
ntuples
;
double
ntuples
;
...
@@ -581,10 +582,18 @@ cost_mergejoin(Path *path, Query *root,
...
@@ -581,10 +582,18 @@ cost_mergejoin(Path *path, Query *root,
* Estimate fraction of the left and right inputs that will actually
* Estimate fraction of the left and right inputs that will actually
* need to be scanned. We use only the first (most significant)
* need to be scanned. We use only the first (most significant)
* merge clause for this purpose.
* merge clause for this purpose.
*
* Since this calculation is somewhat expensive, and will be the same
* for all mergejoin paths associated with the merge clause, we cache
* the results in the RestrictInfo node.
*/
*/
mergejoinscansel
(
root
,
firstclause
=
(
RestrictInfo
*
)
lfirst
(
mergeclauses
);
(
Node
*
)
((
RestrictInfo
*
)
lfirst
(
mergeclauses
))
->
clause
,
if
(
firstclause
->
left_mergescansel
<
0
)
/* not computed yet? */
&
leftscan
,
&
rightscan
);
mergejoinscansel
(
root
,
(
Node
*
)
firstclause
->
clause
,
&
firstclause
->
left_mergescansel
,
&
firstclause
->
right_mergescansel
);
leftscan
=
firstclause
->
left_mergescansel
;
rightscan
=
firstclause
->
right_mergescansel
;
outer_rows
=
outer_path
->
parent
->
rows
*
leftscan
;
outer_rows
=
outer_path
->
parent
->
rows
*
leftscan
;
inner_rows
=
inner_path
->
parent
->
rows
*
rightscan
;
inner_rows
=
inner_path
->
parent
->
rows
*
rightscan
;
...
@@ -1099,9 +1108,9 @@ cost_qual_eval_walker(Node *node, Cost *total)
...
@@ -1099,9 +1108,9 @@ cost_qual_eval_walker(Node *node, Cost *total)
* big difference.)
* big difference.)
*
*
* The "dirty" part comes from the fact that the selectivities of multiple
* The "dirty" part comes from the fact that the selectivities of multiple
* clauses are estimated independently and multiplied together.
Currently,
* clauses are estimated independently and multiplied together.
Now
* clauselist_selectivity
can seldom
do any better than that anyhow, but
* clauselist_selectivity
often can't
do any better than that anyhow, but
*
someday it might be
smarter.
*
for some situations (such as range constraints) it is
smarter.
*
*
* Since we are only using the results to estimate how many potential
* Since we are only using the results to estimate how many potential
* output tuples are generated and passed through qpqual checking, it
* output tuples are generated and passed through qpqual checking, it
...
...
src/backend/optimizer/plan/initsplan.c
View file @
8f0a9e85
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.6
5 2001/10/25 05:49:33 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.6
6 2002/03/01 06:01:19 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -370,6 +370,8 @@ distribute_qual_to_rels(Query *root, Node *clause,
...
@@ -370,6 +370,8 @@ distribute_qual_to_rels(Query *root, Node *clause,
restrictinfo
->
right_sortop
=
InvalidOid
;
restrictinfo
->
right_sortop
=
InvalidOid
;
restrictinfo
->
left_pathkey
=
NIL
;
/* not computable yet */
restrictinfo
->
left_pathkey
=
NIL
;
/* not computable yet */
restrictinfo
->
right_pathkey
=
NIL
;
restrictinfo
->
right_pathkey
=
NIL
;
restrictinfo
->
left_mergescansel
=
-
1
;
/* not computed until needed */
restrictinfo
->
right_mergescansel
=
-
1
;
restrictinfo
->
hashjoinoperator
=
InvalidOid
;
restrictinfo
->
hashjoinoperator
=
InvalidOid
;
restrictinfo
->
left_bucketsize
=
-
1
;
/* not computed until needed */
restrictinfo
->
left_bucketsize
=
-
1
;
/* not computed until needed */
restrictinfo
->
right_bucketsize
=
-
1
;
restrictinfo
->
right_bucketsize
=
-
1
;
...
...
src/backend/optimizer/prep/prepunion.c
View file @
8f0a9e85
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.
69 2001/11/12 20:04
:20 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.
70 2002/03/01 06:01
:20 tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -777,6 +777,8 @@ adjust_inherited_attrs_mutator(Node *node,
...
@@ -777,6 +777,8 @@ adjust_inherited_attrs_mutator(Node *node,
newinfo
->
this_selec
=
-
1
;
newinfo
->
this_selec
=
-
1
;
newinfo
->
left_pathkey
=
NIL
;
/* and these */
newinfo
->
left_pathkey
=
NIL
;
/* and these */
newinfo
->
right_pathkey
=
NIL
;
newinfo
->
right_pathkey
=
NIL
;
newinfo
->
left_mergescansel
=
-
1
;
newinfo
->
right_mergescansel
=
-
1
;
newinfo
->
left_bucketsize
=
-
1
;
newinfo
->
left_bucketsize
=
-
1
;
newinfo
->
right_bucketsize
=
-
1
;
newinfo
->
right_bucketsize
=
-
1
;
...
...
src/include/nodes/relation.h
View file @
8f0a9e85
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: relation.h,v 1.6
1 2001/11/05 17:46:34 momjian
Exp $
* $Id: relation.h,v 1.6
2 2002/03/01 06:01:20 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -521,6 +521,10 @@ typedef struct RestrictInfo
...
@@ -521,6 +521,10 @@ typedef struct RestrictInfo
List
*
left_pathkey
;
/* canonical pathkey for left side */
List
*
left_pathkey
;
/* canonical pathkey for left side */
List
*
right_pathkey
;
/* canonical pathkey for right side */
List
*
right_pathkey
;
/* canonical pathkey for right side */
/* cache space for mergeclause processing; -1 if not yet set */
Selectivity
left_mergescansel
;
/* fraction of left side to scan */
Selectivity
right_mergescansel
;
/* fraction of right side to scan */
/* valid if clause is hashjoinable, else InvalidOid: */
/* valid if clause is hashjoinable, else InvalidOid: */
Oid
hashjoinoperator
;
/* copy of clause operator */
Oid
hashjoinoperator
;
/* copy of clause operator */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment