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
34f8ee97
Commit
34f8ee97
authored
Jan 14, 2006
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add selectivity-calculation code for RowCompareExpr nodes. Simplistic,
but a lot better than nothing at all ...
parent
39fc1fb0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
3 deletions
+73
-3
src/backend/optimizer/path/clausesel.c
src/backend/optimizer/path/clausesel.c
+9
-1
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/selfuncs.c
+60
-1
src/include/utils/selfuncs.h
src/include/utils/selfuncs.h
+4
-1
No files found.
src/backend/optimizer/path/clausesel.c
View file @
34f8ee97
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.7
6 2005/11/25 19:47:49
tgl Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.7
7 2006/01/14 00:14:11
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -663,6 +663,14 @@ clause_selectivity(PlannerInfo *root,
varRelid
,
jointype
);
}
else
if
(
IsA
(
clause
,
RowCompareExpr
))
{
/* Use node specific selectivity calculation function */
s1
=
rowcomparesel
(
root
,
(
RowCompareExpr
*
)
clause
,
varRelid
,
jointype
);
}
else
if
(
IsA
(
clause
,
NullTest
))
{
/* Use node specific selectivity calculation function */
...
...
src/backend/utils/adt/selfuncs.c
View file @
34f8ee97
...
...
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.19
5 2006/01/10 17:35:52
tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.19
6 2006/01/14 00:14:11
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1566,6 +1566,65 @@ scalararraysel(PlannerInfo *root,
return
s1
;
}
/*
* rowcomparesel - Selectivity of RowCompareExpr Node.
*
* We estimate RowCompare selectivity by considering just the first (high
* order) columns, which makes it equivalent to an ordinary OpExpr. While
* this estimate could be refined by considering additional columns, it
* seems unlikely that we could do a lot better without multi-column
* statistics.
*/
Selectivity
rowcomparesel
(
PlannerInfo
*
root
,
RowCompareExpr
*
clause
,
int
varRelid
,
JoinType
jointype
)
{
Selectivity
s1
;
Oid
opno
=
linitial_oid
(
clause
->
opnos
);
List
*
opargs
;
bool
is_join_clause
;
/* Build equivalent arg list for single operator */
opargs
=
list_make2
(
linitial
(
clause
->
largs
),
linitial
(
clause
->
rargs
));
/* Decide if it's a join clause, same as for OpExpr */
if
(
varRelid
!=
0
)
{
/*
* If we are considering a nestloop join then all clauses are
* restriction clauses, since we are only interested in the one
* relation.
*/
is_join_clause
=
false
;
}
else
{
/*
* Otherwise, it's a join if there's more than one relation used.
* Notice we ignore the low-order columns here.
*/
is_join_clause
=
(
NumRelids
((
Node
*
)
opargs
)
>
1
);
}
if
(
is_join_clause
)
{
/* Estimate selectivity for a join clause. */
s1
=
join_selectivity
(
root
,
opno
,
opargs
,
jointype
);
}
else
{
/* Estimate selectivity for a restriction clause. */
s1
=
restriction_selectivity
(
root
,
opno
,
opargs
,
varRelid
);
}
return
s1
;
}
/*
* eqjoinsel - Join selectivity of "="
*/
...
...
src/include/utils/selfuncs.h
View file @
34f8ee97
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/selfuncs.h,v 1.2
6 2005/11/25 19:47:50
tgl Exp $
* $PostgreSQL: pgsql/src/include/utils/selfuncs.h,v 1.2
7 2006/01/14 00:14:12
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -116,6 +116,9 @@ extern Selectivity scalararraysel(PlannerInfo *root,
ScalarArrayOpExpr
*
clause
,
bool
is_join_clause
,
int
varRelid
,
JoinType
jointype
);
extern
Selectivity
rowcomparesel
(
PlannerInfo
*
root
,
RowCompareExpr
*
clause
,
int
varRelid
,
JoinType
jointype
);
extern
void
mergejoinscansel
(
PlannerInfo
*
root
,
Node
*
clause
,
Selectivity
*
leftscan
,
...
...
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