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
12992ab3
Commit
12992ab3
authored
Oct 03, 2005
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate out the VacRUsage stuff as an independent module, in preparation
for using it for other things besides VACUUM.
parent
9c873828
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
155 additions
and
112 deletions
+155
-112
src/backend/commands/vacuum.c
src/backend/commands/vacuum.c
+18
-71
src/backend/commands/vacuumlazy.c
src/backend/commands/vacuumlazy.c
+22
-21
src/backend/utils/misc/Makefile
src/backend/utils/misc/Makefile
+2
-2
src/backend/utils/misc/pg_rusage.c
src/backend/utils/misc/pg_rusage.c
+75
-0
src/include/commands/vacuum.h
src/include/commands/vacuum.h
+1
-18
src/include/utils/pg_rusage.h
src/include/utils/pg_rusage.h
+37
-0
No files found.
src/backend/commands/vacuum.c
View file @
12992ab3
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.31
5 2005/09/22 17:32:58
tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.31
6 2005/10/03 22:52:21
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
#include "utils/inval.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/memutils.h"
#include "utils/pg_rusage.h"
#include "utils/relcache.h"
#include "utils/relcache.h"
#include "utils/syscache.h"
#include "utils/syscache.h"
#include "pgstat.h"
#include "pgstat.h"
...
@@ -1233,9 +1234,9 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
...
@@ -1233,9 +1234,9 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
VTupleLink
vtlinks
=
(
VTupleLink
)
palloc
(
100
*
sizeof
(
VTupleLinkData
));
VTupleLink
vtlinks
=
(
VTupleLink
)
palloc
(
100
*
sizeof
(
VTupleLinkData
));
int
num_vtlinks
=
0
;
int
num_vtlinks
=
0
;
int
free_vtlinks
=
100
;
int
free_vtlinks
=
100
;
Vac
RUsage
ru0
;
PG
RUsage
ru0
;
vac_init_rusage
(
&
ru0
);
pg_rusage_init
(
&
ru0
);
relname
=
RelationGetRelationName
(
onerel
);
relname
=
RelationGetRelationName
(
onerel
);
ereport
(
elevel
,
ereport
(
elevel
,
...
@@ -1592,14 +1593,14 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
...
@@ -1592,14 +1593,14 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
"Total free space (including removable row versions) is %.0f bytes.
\n
"
"Total free space (including removable row versions) is %.0f bytes.
\n
"
"%u pages are or will become empty, including %u at the end of the table.
\n
"
"%u pages are or will become empty, including %u at the end of the table.
\n
"
"%u pages containing %.0f free bytes are potential move destinations.
\n
"
"%u pages containing %.0f free bytes are potential move destinations.
\n
"
"%s"
,
"%s
.
"
,
nkeep
,
nkeep
,
(
unsigned
long
)
min_tlen
,
(
unsigned
long
)
max_tlen
,
(
unsigned
long
)
min_tlen
,
(
unsigned
long
)
max_tlen
,
nunused
,
nunused
,
free_space
,
free_space
,
empty_pages
,
empty_end_pages
,
empty_pages
,
empty_end_pages
,
fraged_pages
->
num_pages
,
usable_free_space
,
fraged_pages
->
num_pages
,
usable_free_space
,
vac_show_rusage
(
&
ru0
))));
pg_rusage_show
(
&
ru0
))));
}
}
...
@@ -1636,9 +1637,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
...
@@ -1636,9 +1637,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
num_fraged_pages
,
num_fraged_pages
,
vacuumed_pages
;
vacuumed_pages
;
int
keep_tuples
=
0
;
int
keep_tuples
=
0
;
Vac
RUsage
ru0
;
PG
RUsage
ru0
;
vac_init_rusage
(
&
ru0
);
pg_rusage_init
(
&
ru0
);
ExecContext_Init
(
&
ec
,
onerel
);
ExecContext_Init
(
&
ec
,
onerel
);
...
@@ -2362,8 +2363,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
...
@@ -2362,8 +2363,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
(
errmsg
(
"
\"
%s
\"
: moved %u row versions, truncated %u to %u pages"
,
(
errmsg
(
"
\"
%s
\"
: moved %u row versions, truncated %u to %u pages"
,
RelationGetRelationName
(
onerel
),
RelationGetRelationName
(
onerel
),
num_moved
,
nblocks
,
blkno
),
num_moved
,
nblocks
,
blkno
),
errdetail
(
"%s"
,
errdetail
(
"%s
.
"
,
vac_show_rusage
(
&
ru0
))));
pg_rusage_show
(
&
ru0
))));
/*
/*
* Reflect the motion of system tuples to catalog cache here.
* Reflect the motion of system tuples to catalog cache here.
...
@@ -2950,9 +2951,9 @@ scan_index(Relation indrel, double num_tuples)
...
@@ -2950,9 +2951,9 @@ scan_index(Relation indrel, double num_tuples)
{
{
IndexBulkDeleteResult
*
stats
;
IndexBulkDeleteResult
*
stats
;
IndexVacuumCleanupInfo
vcinfo
;
IndexVacuumCleanupInfo
vcinfo
;
Vac
RUsage
ru0
;
PG
RUsage
ru0
;
vac_init_rusage
(
&
ru0
);
pg_rusage_init
(
&
ru0
);
/*
/*
* Even though we're not planning to delete anything, we use the
* Even though we're not planning to delete anything, we use the
...
@@ -2982,9 +2983,9 @@ scan_index(Relation indrel, double num_tuples)
...
@@ -2982,9 +2983,9 @@ scan_index(Relation indrel, double num_tuples)
stats
->
num_index_tuples
,
stats
->
num_index_tuples
,
stats
->
num_pages
),
stats
->
num_pages
),
errdetail
(
"%u index pages have been deleted, %u are currently reusable.
\n
"
errdetail
(
"%u index pages have been deleted, %u are currently reusable.
\n
"
"%s"
,
"%s
.
"
,
stats
->
pages_deleted
,
stats
->
pages_free
,
stats
->
pages_deleted
,
stats
->
pages_free
,
vac_show_rusage
(
&
ru0
))));
pg_rusage_show
(
&
ru0
))));
/*
/*
* Check for tuple count mismatch. If the index is partial, then it's
* Check for tuple count mismatch. If the index is partial, then it's
...
@@ -3022,9 +3023,9 @@ vacuum_index(VacPageList vacpagelist, Relation indrel,
...
@@ -3022,9 +3023,9 @@ vacuum_index(VacPageList vacpagelist, Relation indrel,
{
{
IndexBulkDeleteResult
*
stats
;
IndexBulkDeleteResult
*
stats
;
IndexVacuumCleanupInfo
vcinfo
;
IndexVacuumCleanupInfo
vcinfo
;
Vac
RUsage
ru0
;
PG
RUsage
ru0
;
vac_init_rusage
(
&
ru0
);
pg_rusage_init
(
&
ru0
);
/* Do bulk deletion */
/* Do bulk deletion */
stats
=
index_bulk_delete
(
indrel
,
tid_reaped
,
(
void
*
)
vacpagelist
);
stats
=
index_bulk_delete
(
indrel
,
tid_reaped
,
(
void
*
)
vacpagelist
);
...
@@ -3050,10 +3051,10 @@ vacuum_index(VacPageList vacpagelist, Relation indrel,
...
@@ -3050,10 +3051,10 @@ vacuum_index(VacPageList vacpagelist, Relation indrel,
stats
->
num_pages
),
stats
->
num_pages
),
errdetail
(
"%.0f index row versions were removed.
\n
"
errdetail
(
"%.0f index row versions were removed.
\n
"
"%u index pages have been deleted, %u are currently reusable.
\n
"
"%u index pages have been deleted, %u are currently reusable.
\n
"
"%s"
,
"%s
.
"
,
stats
->
tuples_removed
,
stats
->
tuples_removed
,
stats
->
pages_deleted
,
stats
->
pages_free
,
stats
->
pages_deleted
,
stats
->
pages_free
,
vac_show_rusage
(
&
ru0
))));
pg_rusage_show
(
&
ru0
))));
/*
/*
* Check for tuple count mismatch. If the index is partial, then it's
* Check for tuple count mismatch. If the index is partial, then it's
...
@@ -3429,60 +3430,6 @@ enough_space(VacPage vacpage, Size len)
...
@@ -3429,60 +3430,6 @@ enough_space(VacPage vacpage, Size len)
}
}
/*
* Initialize usage snapshot.
*/
void
vac_init_rusage
(
VacRUsage
*
ru0
)
{
struct
timezone
tz
;
getrusage
(
RUSAGE_SELF
,
&
ru0
->
ru
);
gettimeofday
(
&
ru0
->
tv
,
&
tz
);
}
/*
* Compute elapsed time since ru0 usage snapshot, and format into
* a displayable string. Result is in a static string, which is
* tacky, but no one ever claimed that the Postgres backend is
* threadable...
*/
const
char
*
vac_show_rusage
(
VacRUsage
*
ru0
)
{
static
char
result
[
100
];
VacRUsage
ru1
;
vac_init_rusage
(
&
ru1
);
if
(
ru1
.
tv
.
tv_usec
<
ru0
->
tv
.
tv_usec
)
{
ru1
.
tv
.
tv_sec
--
;
ru1
.
tv
.
tv_usec
+=
1000000
;
}
if
(
ru1
.
ru
.
ru_stime
.
tv_usec
<
ru0
->
ru
.
ru_stime
.
tv_usec
)
{
ru1
.
ru
.
ru_stime
.
tv_sec
--
;
ru1
.
ru
.
ru_stime
.
tv_usec
+=
1000000
;
}
if
(
ru1
.
ru
.
ru_utime
.
tv_usec
<
ru0
->
ru
.
ru_utime
.
tv_usec
)
{
ru1
.
ru
.
ru_utime
.
tv_sec
--
;
ru1
.
ru
.
ru_utime
.
tv_usec
+=
1000000
;
}
snprintf
(
result
,
sizeof
(
result
),
"CPU %d.%02ds/%d.%02du sec elapsed %d.%02d sec."
,
(
int
)
(
ru1
.
ru
.
ru_stime
.
tv_sec
-
ru0
->
ru
.
ru_stime
.
tv_sec
),
(
int
)
(
ru1
.
ru
.
ru_stime
.
tv_usec
-
ru0
->
ru
.
ru_stime
.
tv_usec
)
/
10000
,
(
int
)
(
ru1
.
ru
.
ru_utime
.
tv_sec
-
ru0
->
ru
.
ru_utime
.
tv_sec
),
(
int
)
(
ru1
.
ru
.
ru_utime
.
tv_usec
-
ru0
->
ru
.
ru_utime
.
tv_usec
)
/
10000
,
(
int
)
(
ru1
.
tv
.
tv_sec
-
ru0
->
tv
.
tv_sec
),
(
int
)
(
ru1
.
tv
.
tv_usec
-
ru0
->
tv
.
tv_usec
)
/
10000
);
return
result
;
}
/*
/*
* vacuum_delay_point --- check for interrupts and cost-based delay.
* vacuum_delay_point --- check for interrupts and cost-based delay.
*
*
...
...
src/backend/commands/vacuumlazy.c
View file @
12992ab3
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.
59 2005/09/22 17:32:58
tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.
60 2005/10/03 22:52:22
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -48,6 +48,7 @@
...
@@ -48,6 +48,7 @@
#include "storage/freespace.h"
#include "storage/freespace.h"
#include "storage/smgr.h"
#include "storage/smgr.h"
#include "utils/lsyscache.h"
#include "utils/lsyscache.h"
#include "utils/pg_rusage.h"
/*
/*
...
@@ -209,9 +210,9 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
...
@@ -209,9 +210,9 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
BlockNumber
*
index_pages_removed
;
BlockNumber
*
index_pages_removed
;
bool
did_vacuum_index
=
false
;
bool
did_vacuum_index
=
false
;
int
i
;
int
i
;
Vac
RUsage
ru0
;
PG
RUsage
ru0
;
vac_init_rusage
(
&
ru0
);
pg_rusage_init
(
&
ru0
);
relname
=
RelationGetRelationName
(
onerel
);
relname
=
RelationGetRelationName
(
onerel
);
ereport
(
elevel
,
ereport
(
elevel
,
...
@@ -478,11 +479,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
...
@@ -478,11 +479,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
errdetail
(
"%.0f dead row versions cannot be removed yet.
\n
"
errdetail
(
"%.0f dead row versions cannot be removed yet.
\n
"
"There were %.0f unused item pointers.
\n
"
"There were %.0f unused item pointers.
\n
"
"%u pages are entirely empty.
\n
"
"%u pages are entirely empty.
\n
"
"%s"
,
"%s
.
"
,
nkeep
,
nkeep
,
nunused
,
nunused
,
empty_pages
,
empty_pages
,
vac_show_rusage
(
&
ru0
))));
pg_rusage_show
(
&
ru0
))));
}
}
...
@@ -502,9 +503,9 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
...
@@ -502,9 +503,9 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
{
{
int
tupindex
;
int
tupindex
;
int
npages
;
int
npages
;
Vac
RUsage
ru0
;
PG
RUsage
ru0
;
vac_init_rusage
(
&
ru0
);
pg_rusage_init
(
&
ru0
);
npages
=
0
;
npages
=
0
;
tupindex
=
0
;
tupindex
=
0
;
...
@@ -533,8 +534,8 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
...
@@ -533,8 +534,8 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
(
errmsg
(
"
\"
%s
\"
: removed %d row versions in %d pages"
,
(
errmsg
(
"
\"
%s
\"
: removed %d row versions in %d pages"
,
RelationGetRelationName
(
onerel
),
RelationGetRelationName
(
onerel
),
tupindex
,
npages
),
tupindex
,
npages
),
errdetail
(
"%s"
,
errdetail
(
"%s
.
"
,
vac_show_rusage
(
&
ru0
))));
pg_rusage_show
(
&
ru0
))));
}
}
/*
/*
...
@@ -602,9 +603,9 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
...
@@ -602,9 +603,9 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
{
{
IndexBulkDeleteResult
*
stats
;
IndexBulkDeleteResult
*
stats
;
IndexVacuumCleanupInfo
vcinfo
;
IndexVacuumCleanupInfo
vcinfo
;
Vac
RUsage
ru0
;
PG
RUsage
ru0
;
vac_init_rusage
(
&
ru0
);
pg_rusage_init
(
&
ru0
);
/*
/*
* Acquire appropriate type of lock on index: must be exclusive if
* Acquire appropriate type of lock on index: must be exclusive if
...
@@ -652,9 +653,9 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
...
@@ -652,9 +653,9 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
stats
->
num_index_tuples
,
stats
->
num_index_tuples
,
stats
->
num_pages
),
stats
->
num_pages
),
errdetail
(
"%u index pages have been deleted, %u are currently reusable.
\n
"
errdetail
(
"%u index pages have been deleted, %u are currently reusable.
\n
"
"%s"
,
"%s
.
"
,
stats
->
pages_deleted
,
stats
->
pages_free
,
stats
->
pages_deleted
,
stats
->
pages_free
,
vac_show_rusage
(
&
ru0
))));
pg_rusage_show
(
&
ru0
))));
pfree
(
stats
);
pfree
(
stats
);
}
}
...
@@ -679,9 +680,9 @@ lazy_vacuum_index(Relation indrel,
...
@@ -679,9 +680,9 @@ lazy_vacuum_index(Relation indrel,
{
{
IndexBulkDeleteResult
*
stats
;
IndexBulkDeleteResult
*
stats
;
IndexVacuumCleanupInfo
vcinfo
;
IndexVacuumCleanupInfo
vcinfo
;
Vac
RUsage
ru0
;
PG
RUsage
ru0
;
vac_init_rusage
(
&
ru0
);
pg_rusage_init
(
&
ru0
);
/*
/*
* Acquire appropriate type of lock on index: must be exclusive if
* Acquire appropriate type of lock on index: must be exclusive if
...
@@ -729,10 +730,10 @@ lazy_vacuum_index(Relation indrel,
...
@@ -729,10 +730,10 @@ lazy_vacuum_index(Relation indrel,
stats
->
num_pages
),
stats
->
num_pages
),
errdetail
(
"%.0f index row versions were removed.
\n
"
errdetail
(
"%.0f index row versions were removed.
\n
"
"%u index pages have been deleted, %u are currently reusable.
\n
"
"%u index pages have been deleted, %u are currently reusable.
\n
"
"%s"
,
"%s
.
"
,
stats
->
tuples_removed
,
stats
->
tuples_removed
,
stats
->
pages_deleted
,
stats
->
pages_free
,
stats
->
pages_deleted
,
stats
->
pages_free
,
vac_show_rusage
(
&
ru0
))));
pg_rusage_show
(
&
ru0
))));
pfree
(
stats
);
pfree
(
stats
);
}
}
...
@@ -749,9 +750,9 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
...
@@ -749,9 +750,9 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
int
n
;
int
n
;
int
i
,
int
i
,
j
;
j
;
Vac
RUsage
ru0
;
PG
RUsage
ru0
;
vac_init_rusage
(
&
ru0
);
pg_rusage_init
(
&
ru0
);
/*
/*
* We need full exclusive lock on the relation in order to do
* We need full exclusive lock on the relation in order to do
...
@@ -828,8 +829,8 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
...
@@ -828,8 +829,8 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
(
errmsg
(
"
\"
%s
\"
: truncated %u to %u pages"
,
(
errmsg
(
"
\"
%s
\"
: truncated %u to %u pages"
,
RelationGetRelationName
(
onerel
),
RelationGetRelationName
(
onerel
),
old_rel_pages
,
new_rel_pages
),
old_rel_pages
,
new_rel_pages
),
errdetail
(
"%s"
,
errdetail
(
"%s
.
"
,
vac_show_rusage
(
&
ru0
))));
pg_rusage_show
(
&
ru0
))));
}
}
/*
/*
...
...
src/backend/utils/misc/Makefile
View file @
12992ab3
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
# Makefile for utils/misc
# Makefile for utils/misc
#
#
# IDENTIFICATION
# IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/utils/misc/Makefile,v 1.2
3 2005/02/26 18:43:3
3 tgl Exp $
# $PostgreSQL: pgsql/src/backend/utils/misc/Makefile,v 1.2
4 2005/10/03 22:52:2
3 tgl Exp $
#
#
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
...
@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
...
@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS
:
= -I$(srcdir) $(CPPFLAGS)
override CPPFLAGS
:
= -I$(srcdir) $(CPPFLAGS)
OBJS
=
guc.o help_config.o ps_status.o superuser.o
OBJS
=
guc.o help_config.o p
g_rusage.o p
s_status.o superuser.o
# This location might depend on the installation directories. Therefore
# This location might depend on the installation directories. Therefore
# we can't subsitute it into pg_config.h.
# we can't subsitute it into pg_config.h.
...
...
src/backend/utils/misc/pg_rusage.c
0 → 100644
View file @
12992ab3
/*-------------------------------------------------------------------------
*
* pg_rusage.c
* Resource usage measurement support routines.
*
*
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/pg_rusage.c,v 1.1 2005/10/03 22:52:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <unistd.h>
#include "utils/pg_rusage.h"
/*
* Initialize usage snapshot.
*/
void
pg_rusage_init
(
PGRUsage
*
ru0
)
{
struct
timezone
tz
;
getrusage
(
RUSAGE_SELF
,
&
ru0
->
ru
);
gettimeofday
(
&
ru0
->
tv
,
&
tz
);
}
/*
* Compute elapsed time since ru0 usage snapshot, and format into
* a displayable string. Result is in a static string, which is
* tacky, but no one ever claimed that the Postgres backend is
* threadable...
*/
const
char
*
pg_rusage_show
(
const
PGRUsage
*
ru0
)
{
static
char
result
[
100
];
PGRUsage
ru1
;
pg_rusage_init
(
&
ru1
);
if
(
ru1
.
tv
.
tv_usec
<
ru0
->
tv
.
tv_usec
)
{
ru1
.
tv
.
tv_sec
--
;
ru1
.
tv
.
tv_usec
+=
1000000
;
}
if
(
ru1
.
ru
.
ru_stime
.
tv_usec
<
ru0
->
ru
.
ru_stime
.
tv_usec
)
{
ru1
.
ru
.
ru_stime
.
tv_sec
--
;
ru1
.
ru
.
ru_stime
.
tv_usec
+=
1000000
;
}
if
(
ru1
.
ru
.
ru_utime
.
tv_usec
<
ru0
->
ru
.
ru_utime
.
tv_usec
)
{
ru1
.
ru
.
ru_utime
.
tv_sec
--
;
ru1
.
ru
.
ru_utime
.
tv_usec
+=
1000000
;
}
snprintf
(
result
,
sizeof
(
result
),
"CPU %d.%02ds/%d.%02du sec elapsed %d.%02d sec"
,
(
int
)
(
ru1
.
ru
.
ru_stime
.
tv_sec
-
ru0
->
ru
.
ru_stime
.
tv_sec
),
(
int
)
(
ru1
.
ru
.
ru_stime
.
tv_usec
-
ru0
->
ru
.
ru_stime
.
tv_usec
)
/
10000
,
(
int
)
(
ru1
.
ru
.
ru_utime
.
tv_sec
-
ru0
->
ru
.
ru_utime
.
tv_sec
),
(
int
)
(
ru1
.
ru
.
ru_utime
.
tv_usec
-
ru0
->
ru
.
ru_utime
.
tv_usec
)
/
10000
,
(
int
)
(
ru1
.
tv
.
tv_sec
-
ru0
->
tv
.
tv_sec
),
(
int
)
(
ru1
.
tv
.
tv_usec
-
ru0
->
tv
.
tv_usec
)
/
10000
);
return
result
;
}
src/include/commands/vacuum.h
View file @
12992ab3
...
@@ -7,21 +7,13 @@
...
@@ -7,21 +7,13 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.6
0 2005/07/14 05:13:43
tgl Exp $
* $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.6
1 2005/10/03 22:52:24
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
#ifndef VACUUM_H
#ifndef VACUUM_H
#define VACUUM_H
#define VACUUM_H
#include <sys/time.h>
#ifdef HAVE_GETRUSAGE
#include <sys/resource.h>
#else
#include "rusagestub.h"
#endif
#include "access/htup.h"
#include "access/htup.h"
#include "catalog/pg_attribute.h"
#include "catalog/pg_attribute.h"
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic.h"
...
@@ -113,13 +105,6 @@ typedef struct VacAttrStats
...
@@ -113,13 +105,6 @@ typedef struct VacAttrStats
}
VacAttrStats
;
}
VacAttrStats
;
/* State structure for vac_init_rusage/vac_show_rusage */
typedef
struct
VacRUsage
{
struct
timeval
tv
;
struct
rusage
ru
;
}
VacRUsage
;
/* Default statistics target (GUC parameter) */
/* Default statistics target (GUC parameter) */
extern
DLLIMPORT
int
default_statistics_target
;
/* DLLIMPORT for PostGIS */
extern
DLLIMPORT
int
default_statistics_target
;
/* DLLIMPORT for PostGIS */
...
@@ -137,8 +122,6 @@ extern void vacuum_set_xid_limits(VacuumStmt *vacstmt, bool sharedRel,
...
@@ -137,8 +122,6 @@ extern void vacuum_set_xid_limits(VacuumStmt *vacstmt, bool sharedRel,
TransactionId
*
oldestXmin
,
TransactionId
*
oldestXmin
,
TransactionId
*
freezeLimit
);
TransactionId
*
freezeLimit
);
extern
bool
vac_is_partial_index
(
Relation
indrel
);
extern
bool
vac_is_partial_index
(
Relation
indrel
);
extern
void
vac_init_rusage
(
VacRUsage
*
ru0
);
extern
const
char
*
vac_show_rusage
(
VacRUsage
*
ru0
);
extern
void
vacuum_delay_point
(
void
);
extern
void
vacuum_delay_point
(
void
);
/* in commands/vacuumlazy.c */
/* in commands/vacuumlazy.c */
...
...
src/include/utils/pg_rusage.h
0 → 100644
View file @
12992ab3
/*-------------------------------------------------------------------------
*
* pg_rusage.h
* header file for resource usage measurement support routines
*
*
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/pg_rusage.h,v 1.1 2005/10/03 22:52:26 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PG_RUSAGE_H
#define PG_RUSAGE_H
#include <sys/time.h>
#ifdef HAVE_GETRUSAGE
#include <sys/resource.h>
#else
#include "rusagestub.h"
#endif
/* State structure for pg_rusage_init/pg_rusage_show */
typedef
struct
PGRUsage
{
struct
timeval
tv
;
struct
rusage
ru
;
}
PGRUsage
;
extern
void
pg_rusage_init
(
PGRUsage
*
ru0
);
extern
const
char
*
pg_rusage_show
(
const
PGRUsage
*
ru0
);
#endif
/* PG_RUSAGE_H */
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