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
67712200
Commit
67712200
authored
Apr 24, 1997
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Hack for non-functional btree npages estimation:
* npages = index_pages * selectivity_of_1st_attr_clause(s)
parent
72d27117
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
7 deletions
+34
-7
src/backend/optimizer/util/plancat.c
src/backend/optimizer/util/plancat.c
+34
-7
No files found.
src/backend/optimizer/util/plancat.c
View file @
67712200
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.
5 1997/04/09 01:52:0
4 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.
6 1997/04/24 16:07:1
4 vadim Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -499,6 +499,8 @@ IndexSelectivity(Oid indexrelid,
float64data
npages
,
select
;
float64
amopnpages
,
amopselect
;
Oid
relam
;
bool
nphack
=
false
;
float64data
fattr_select
=
1
.
0
;
indRel
=
SearchSysCacheTuple
(
RELOID
,
ObjectIdGetDatum
(
indexrelid
),
...
...
@@ -515,6 +517,15 @@ IndexSelectivity(Oid indexrelid,
elog
(
WARN
,
"IndexSelectivity: index %d not found"
,
indexrelid
);
index
=
(
IndexTupleForm
)
GETSTRUCT
(
indexTuple
);
/*
* Hack for non-functional btree npages estimation:
* npages = index_pages * selectivity_of_1st_attr_clause(s)
* - vadim 04/24/97
*/
if
(
relam
==
BTREE_AM_OID
&&
varAttributeNumbers
[
0
]
!=
InvalidAttrNumber
)
nphack
=
true
;
npages
=
0
.
0
;
select
=
1
.
0
;
...
...
@@ -556,7 +567,10 @@ IndexSelectivity(Oid indexrelid,
elog
(
WARN
,
"IndexSelectivity: no amop %d %d"
,
indclass
,
operatorObjectIds
[
n
]);
amop
=
(
Form_pg_amop
)
GETSTRUCT
(
amopTuple
);
amopnpages
=
(
float64
)
fmgr
(
amop
->
amopnpages
,
if
(
!
nphack
)
{
amopnpages
=
(
float64
)
fmgr
(
amop
->
amopnpages
,
(
char
*
)
operatorObjectIds
[
n
],
(
char
*
)
indrelid
,
(
char
*
)
varAttributeNumbers
[
n
],
...
...
@@ -573,8 +587,9 @@ IndexSelectivity(Oid indexrelid,
if ((i = npages) < npages) /* ceil(npages)? */
npages += 1.0;
#endif
npages
+=
PointerIsValid
(
amopnpages
)
?
*
amopnpages
:
0
.
0
;
npages
+=
PointerIsValid
(
amopnpages
)
?
*
amopnpages
:
0
.
0
;
}
amopselect
=
(
float64
)
fmgr
(
amop
->
amopselect
,
(
char
*
)
operatorObjectIds
[
n
],
(
char
*
)
indrelid
,
...
...
@@ -583,15 +598,27 @@ IndexSelectivity(Oid indexrelid,
(
char
*
)
constFlags
[
n
],
(
char
*
)
nIndexKeys
,
(
char
*
)
indexrelid
);
if
(
nphack
&&
varAttributeNumbers
[
n
]
==
index
->
indkey
[
0
]
)
fattr_select
*=
PointerIsValid
(
amopselect
)
?
*
amopselect
:
1
.
0
;
select
*=
PointerIsValid
(
amopselect
)
?
*
amopselect
:
1
.
0
;
}
/*
* Estimation of npages below is hack of course, but it's
* better than it was before. - vadim 04/09/97
*/
if
(
nIndexKeys
>
1
)
npages
=
npages
/
(
1
.
0
+
nIndexKeys
);
*
idxPages
=
ceil
((
double
)(
npages
/
nIndexKeys
));
if
(
nphack
)
{
npages
=
fattr_select
*
((
Form_pg_class
)
GETSTRUCT
(
indRel
))
->
relpages
;
*
idxPages
=
ceil
((
double
)
npages
);
}
else
{
if
(
nIndexKeys
>
1
)
npages
=
npages
/
(
1
.
0
+
nIndexKeys
);
*
idxPages
=
ceil
((
double
)(
npages
/
nIndexKeys
));
}
*
idxSelec
=
select
;
}
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