Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
7192cbb0
Commit
7192cbb0
authored
25 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Back-patch fix to recognize clause pairs involving Params
as being range queries.
parent
dbb7553b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/optimizer/path/clausesel.c
+45
-36
45 additions, 36 deletions
src/backend/optimizer/path/clausesel.c
with
45 additions
and
36 deletions
src/backend/optimizer/path/clausesel.c
+
45
−
36
View file @
7192cbb0
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.34 2000/0
4/12 17:15:19 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.34
.2.1
2000/0
5/31 15:43:31 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -95,7 +95,7 @@ restrictlist_selectivity(Query *root,
* directly as a 0..1 value but we need to convert losel to 1-losel before
* interpreting it as a value. Then the available range is 1-losel to hisel.)
* If the calculation yields zero or negative, however, we chicken out and
* use
the
default
interpretation
; that probably means that one or both
* use
a
default
estimate
; that probably means that one or both
* selectivities is a default estimate rather than an actual range value.
* Of course this is all very dependent on the behavior of
* scalarltsel/scalargtsel; perhaps some day we can generalize the approach.
...
...
@@ -120,10 +120,12 @@ clauselist_selectivity(Query *root,
Selectivity
s2
;
/*
* See if it looks like a restriction clause with a constant. (If
* it's not a constant we can't really trust the selectivity!) NB:
* for consistency of results, this fragment of code had better
* match what clause_selectivity() would do.
* See if it looks like a restriction clause with a Const or Param
* on one side. (Anything more complicated than that might not
* behave in the simple way we are expecting.)
*
* NB: for consistency of results, this fragment of code had better
* match what clause_selectivity() would do in the cases it handles.
*/
if
(
varRelid
!=
0
||
NumRelids
(
clause
)
==
1
)
{
...
...
@@ -134,9 +136,15 @@ clauselist_selectivity(Query *root,
get_relattval
(
clause
,
varRelid
,
&
relidx
,
&
attno
,
&
constval
,
&
flag
);
if
(
relidx
!=
0
&&
(
flag
&
SEL_CONSTANT
)
)
if
(
relidx
!=
0
)
{
/* if get_relattval succeeded, it must be an opclause */
Var
*
other
;
other
=
(
flag
&
SEL_RIGHT
)
?
get_rightop
((
Expr
*
)
clause
)
:
get_leftop
((
Expr
*
)
clause
);
if
(
IsA
(
other
,
Const
)
||
IsA
(
other
,
Param
))
{
Oid
opno
=
((
Oper
*
)
((
Expr
*
)
clause
)
->
oper
)
->
opno
;
RegProcedure
oprrest
=
get_oprrest
(
opno
);
...
...
@@ -171,6 +179,7 @@ clauselist_selectivity(Query *root,
continue
;
/* drop to loop bottom */
}
}
}
/* Not the right form, so treat it generically. */
s2
=
clause_selectivity
(
root
,
clause
,
varRelid
);
s1
=
s1
*
s2
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment