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
daf75276
Commit
daf75276
authored
28 years ago
by
Vadim B. Mikheev
Browse files
Options
Downloads
Patches
Plain Diff
New func _vc_scanoneind: scan one index relation to update statistic
in pg_class if no one page was reapped by vacuum.
parent
f3c3458b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/commands/vacuum.c
+63
-13
63 additions, 13 deletions
src/backend/commands/vacuum.c
with
63 additions
and
13 deletions
src/backend/commands/vacuum.c
+
63
−
13
View file @
daf75276
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.1
7
1997/01/2
5 19:29:36 scrappy
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.1
8
1997/01/2
9 02:59:03 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -68,6 +68,7 @@ static void _vc_rpfheap (VRelList curvrl, Relation onerel, VPageList Vvpl, VPage
static
void
_vc_vacheap
(
VRelList
curvrl
,
Relation
onerel
,
VPageList
vpl
);
static
void
_vc_vacpage
(
Page
page
,
VPageDescr
vpd
,
Relation
archrel
);
static
void
_vc_vaconeind
(
VPageList
vpl
,
Relation
indrel
,
int
nhtups
);
static
void
_vc_scanoneind
(
Relation
indrel
,
int
nhtups
);
static
void
_vc_updstats
(
Oid
relid
,
int
npages
,
int
ntuples
,
bool
hasindex
);
static
void
_vc_setpagelock
(
Relation
rel
,
BlockNumber
blkno
);
static
VPageDescr
_vc_tidreapped
(
ItemPointer
itemptr
,
VPageList
curvrl
);
...
...
@@ -400,34 +401,38 @@ _vc_vacone (VRelList curvrl)
Vvpl
.
vpl_npages
=
Fvpl
.
vpl_npages
=
0
;
_vc_scanheap
(
curvrl
,
onerel
,
&
Vvpl
,
&
Fvpl
);
/* Now open
/count
indices */
/* Now open indices */
Irel
=
(
Relation
*
)
NULL
;
if
(
Vvpl
.
vpl_npages
>
0
)
/* Open all indices of this relation */
_vc_getindices
(
curvrl
->
vrl_relid
,
&
nindices
,
&
Irel
);
else
/* Count indices only */
_vc_getindices
(
curvrl
->
vrl_relid
,
&
nindices
,
NULL
);
_vc_getindices
(
curvrl
->
vrl_relid
,
&
nindices
,
&
Irel
);
if
(
nindices
>
0
)
curvrl
->
vrl_hasindex
=
true
;
else
curvrl
->
vrl_hasindex
=
false
;
/* Clean index
'
relation(s) */
/* Clean
/scan
index relation(s) */
if
(
Irel
!=
(
Relation
*
)
NULL
)
{
for
(
i
=
0
;
i
<
nindices
;
i
++
)
_vc_vaconeind
(
&
Vvpl
,
Irel
[
i
],
curvrl
->
vrl_ntups
);
if
(
Vvpl
.
vpl_npages
>
0
)
{
for
(
i
=
0
;
i
<
nindices
;
i
++
)
_vc_vaconeind
(
&
Vvpl
,
Irel
[
i
],
curvrl
->
vrl_ntups
);
}
else
/* just scan indices to update statistic */
{
for
(
i
=
0
;
i
<
nindices
;
i
++
)
_vc_scanoneind
(
Irel
[
i
],
curvrl
->
vrl_ntups
);
}
}
if
(
Fvpl
.
vpl_npages
>
0
)
/* Try to shrink heap */
_vc_rpfheap
(
curvrl
,
onerel
,
&
Vvpl
,
&
Fvpl
,
nindices
,
Irel
);
else
if
(
Vvpl
.
vpl_npages
>
0
)
/* Clean pages from Vvpl list */
else
{
if
(
Irel
!=
(
Relation
*
)
NULL
)
_vc_clsindices
(
nindices
,
Irel
);
_vc_vacheap
(
curvrl
,
onerel
,
&
Vvpl
);
if
(
Vvpl
.
vpl_npages
>
0
)
/* Clean pages from Vvpl list */
_vc_vacheap
(
curvrl
,
onerel
,
&
Vvpl
);
}
/* ok - free Vvpl list of reapped pages */
...
...
@@ -1266,6 +1271,51 @@ _vc_vacpage (Page page, VPageDescr vpd, Relation archrel)
}
/* _vc_vacpage */
/*
* _vc_scanoneind() -- scan one index relation to update statistic.
*
*/
static
void
_vc_scanoneind
(
Relation
indrel
,
int
nhtups
)
{
RetrieveIndexResult
res
;
IndexScanDesc
iscan
;
int
nitups
;
int
nipages
;
struct
rusage
ru0
,
ru1
;
getrusage
(
RUSAGE_SELF
,
&
ru0
);
/* walk through the entire index */
iscan
=
index_beginscan
(
indrel
,
false
,
0
,
(
ScanKey
)
NULL
);
nitups
=
0
;
while
((
res
=
index_getnext
(
iscan
,
ForwardScanDirection
))
!=
(
RetrieveIndexResult
)
NULL
)
{
nitups
++
;
pfree
(
res
);
}
index_endscan
(
iscan
);
/* now update statistics in pg_class */
nipages
=
RelationGetNumberOfBlocks
(
indrel
);
_vc_updstats
(
indrel
->
rd_id
,
nipages
,
nitups
,
false
);
getrusage
(
RUSAGE_SELF
,
&
ru1
);
elog
(
MESSLEV
,
"Ind %.*s: Pages %u; Tuples %u. Elapsed %u/%u sec."
,
NAMEDATALEN
,
indrel
->
rd_rel
->
relname
.
data
,
nipages
,
nitups
,
ru1
.
ru_stime
.
tv_sec
-
ru0
.
ru_stime
.
tv_sec
,
ru1
.
ru_utime
.
tv_sec
-
ru0
.
ru_utime
.
tv_sec
);
if
(
nitups
!=
nhtups
)
elog
(
NOTICE
,
"NUMBER OF INDEX' TUPLES (%u) IS NOT THE SAME AS HEAP' (%u)"
,
nitups
,
nhtups
);
}
/* _vc_scanoneind */
/*
* _vc_vaconeind() -- vacuum one index relation.
*
...
...
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