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
7df721af
Commit
7df721af
authored
24 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Compute reasonable cost and output-row-count estimates for LIMIT plan
nodes.
parent
37c55f98
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/optimizer/plan/createplan.c
+44
-1
44 additions, 1 deletion
src/backend/optimizer/plan/createplan.c
with
44 additions
and
1 deletion
src/backend/optimizer/plan/createplan.c
+
44
−
1
View file @
7df721af
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.10
1
2000/1
1/16 22:30:24
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.10
2
2000/1
2/23 18:49:41
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1733,6 +1733,49 @@ make_limit(List *tlist, Plan *lefttree,
copy_plan_costsize
(
plan
,
lefttree
);
/*
* If offset/count are constants, adjust the output rows count and costs
* accordingly. This is only a cosmetic issue if we are at top level,
* but if we are building a subquery then it's important to report
* correct info to the outer planner.
*/
if
(
limitOffset
&&
IsA
(
limitOffset
,
Const
))
{
Const
*
limito
=
(
Const
*
)
limitOffset
;
int32
offset
=
DatumGetInt32
(
limito
->
constvalue
);
if
(
!
limito
->
constisnull
&&
offset
>
0
)
{
if
(
offset
>
plan
->
plan_rows
)
offset
=
(
int32
)
plan
->
plan_rows
;
if
(
plan
->
plan_rows
>
0
)
plan
->
startup_cost
+=
(
plan
->
total_cost
-
plan
->
startup_cost
)
*
((
double
)
offset
)
/
plan
->
plan_rows
;
plan
->
plan_rows
-=
offset
;
if
(
plan
->
plan_rows
<
1
)
plan
->
plan_rows
=
1
;
}
}
if
(
limitCount
&&
IsA
(
limitCount
,
Const
))
{
Const
*
limitc
=
(
Const
*
)
limitCount
;
int32
count
=
DatumGetInt32
(
limitc
->
constvalue
);
if
(
!
limitc
->
constisnull
&&
count
>=
0
)
{
if
(
count
>
plan
->
plan_rows
)
count
=
(
int32
)
plan
->
plan_rows
;
if
(
plan
->
plan_rows
>
0
)
plan
->
total_cost
=
plan
->
startup_cost
+
(
plan
->
total_cost
-
plan
->
startup_cost
)
*
((
double
)
count
)
/
plan
->
plan_rows
;
plan
->
plan_rows
=
count
;
if
(
plan
->
plan_rows
<
1
)
plan
->
plan_rows
=
1
;
}
}
plan
->
state
=
(
EState
*
)
NULL
;
plan
->
targetlist
=
tlist
;
plan
->
qual
=
NIL
;
...
...
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