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
1d4ee0cc
Commit
1d4ee0cc
authored
Jun 29, 2001
by
Jan Wieck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turned high-frequently called pgstat functions into macros
for speed. Jan
parent
f889b12b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
242 deletions
+61
-242
src/backend/postmaster/pgstat.c
src/backend/postmaster/pgstat.c
+1
-225
src/include/pgstat.h
src/include/pgstat.h
+60
-17
No files found.
src/backend/postmaster/pgstat.c
View file @
1d4ee0cc
...
...
@@ -19,7 +19,7 @@
*
* Copyright (c) 2001, PostgreSQL Global Development Group
*
* $Id: pgstat.c,v 1.
1 2001/06/22 19:18:35
wieck Exp $
* $Id: pgstat.c,v 1.
2 2001/06/29 16:29:37
wieck Exp $
* ----------
*/
#include <stdio.h>
...
...
@@ -757,230 +757,6 @@ pgstat_initstats(PgStat_Info *stats, Relation rel)
}
/* ----------
* pgstat_reset_heap_scan() -
*
* Called from heap_rescan() to reset the heap_scan_counted flag.
* Since the optimizer usually does a beginscan()/endscan() without
* really doing a scan, we cannot count those calls. We have to wait
* if after a beginscan() or rescan() really a call to the getnext()
* function happens.
* ----------
*/
void
pgstat_reset_heap_scan
(
PgStat_Info
*
stats
)
{
if
(
stats
->
tabentry
==
NULL
)
return
;
stats
->
heap_scan_counted
=
FALSE
;
}
/* ----------
* pgstat_count_heap_scan() -
*
* Called from heap_getnext() to tell us that now the relation
* really is scanned.
* ----------
*/
void
pgstat_count_heap_scan
(
PgStat_Info
*
stats
)
{
if
(
stats
->
tabentry
==
NULL
)
return
;
if
(
!
stats
->
heap_scan_counted
)
{
((
PgStat_TableEntry
*
)(
stats
->
tabentry
))
->
t_numscans
++
;
stats
->
heap_scan_counted
=
TRUE
;
}
}
/* ----------
* pgstat_count_heap_getnext() -
*
* Called from heap_getnext() whenever a valid tuple is returned
* from a sequential scan. The above cannot get combined into this,
* because if a heap scan didn't return any tuples, the scan itself
* would be missing in the stats.
* ----------
*/
void
pgstat_count_heap_getnext
(
PgStat_Info
*
stats
)
{
if
(
stats
->
tabentry
==
NULL
)
return
;
((
PgStat_TableEntry
*
)(
stats
->
tabentry
))
->
t_tuples_returned
++
;
}
/* ----------
* pgstat_count_heap_fetch() -
*
* Called from heap_fetch() if this is caused by a heap lookup
* for an actually done index scan.
* ----------
*/
void
pgstat_count_heap_fetch
(
PgStat_Info
*
stats
)
{
if
(
stats
->
tabentry
==
NULL
)
return
;
((
PgStat_TableEntry
*
)(
stats
->
tabentry
))
->
t_tuples_fetched
++
;
}
/* ----------
* pgstat_count_heap_insert() -
*
* Called from heap_insert().
* ----------
*/
void
pgstat_count_heap_insert
(
PgStat_Info
*
stats
)
{
if
(
stats
->
tabentry
==
NULL
)
return
;
((
PgStat_TableEntry
*
)(
stats
->
tabentry
))
->
t_tuples_inserted
++
;
}
/* ----------
* pgstat_count_heap_update() -
*
* Called from heap_update().
* ----------
*/
void
pgstat_count_heap_update
(
PgStat_Info
*
stats
)
{
if
(
stats
->
tabentry
==
NULL
)
return
;
((
PgStat_TableEntry
*
)(
stats
->
tabentry
))
->
t_tuples_updated
++
;
}
/* ----------
* pgstat_count_heap_delete() -
*
* Called from heap_delete().
* ----------
*/
void
pgstat_count_heap_delete
(
PgStat_Info
*
stats
)
{
if
(
stats
->
tabentry
==
NULL
)
return
;
((
PgStat_TableEntry
*
)(
stats
->
tabentry
))
->
t_tuples_deleted
++
;
}
/* ----------
* pgstat_reset_index_scan() -
*
* See pgstat_reset_heap_scan().
* ----------
*/
void
pgstat_reset_index_scan
(
PgStat_Info
*
stats
)
{
if
(
stats
->
tabentry
==
NULL
)
return
;
stats
->
index_scan_counted
=
FALSE
;
}
/* ----------
* pgstat_count_index_scan() -
*
* See pgstat_count_heap_scan().
* ----------
*/
void
pgstat_count_index_scan
(
PgStat_Info
*
stats
)
{
if
(
stats
->
tabentry
==
NULL
)
return
;
if
(
!
stats
->
index_scan_counted
)
{
((
PgStat_TableEntry
*
)(
stats
->
tabentry
))
->
t_numscans
++
;
stats
->
index_scan_counted
=
TRUE
;
}
}
/* ----------
* pgstat_reset_index_getnext() -
*
* See pgstat_count_heap_getnext().
* ----------
*/
void
pgstat_count_index_getnext
(
PgStat_Info
*
stats
)
{
if
(
stats
->
tabentry
==
NULL
)
return
;
((
PgStat_TableEntry
*
)(
stats
->
tabentry
))
->
t_tuples_returned
++
;
}
/* ----------
* pgstat_count_buffer_read() -
*
* Called from bufmgr.c when a buffer is looked up in the shared buffer
* cache. The real number of buffers read from the disk (or at least the
* OSs or drives cache) is this minus buffer_hit_count below.
* ----------
*/
void
pgstat_count_buffer_read
(
PgStat_Info
*
stats
,
Relation
rel
)
{
if
(
stats
->
tabentry
==
NULL
)
{
if
(
stats
->
no_stats
)
return
;
pgstat_initstats
(
stats
,
rel
);
if
(
stats
->
tabentry
==
NULL
)
return
;
}
((
PgStat_TableEntry
*
)(
stats
->
tabentry
))
->
t_blocks_fetched
++
;
}
/* ----------
* pgstat_count_buffer_hit() -
*
* Counts how many buffer per relation (or index) have been found
* in the buffer cache.
* ----------
*/
void
pgstat_count_buffer_hit
(
PgStat_Info
*
stats
,
Relation
rel
)
{
if
(
stats
->
tabentry
==
NULL
)
{
if
(
stats
->
no_stats
)
return
;
pgstat_initstats
(
stats
,
rel
);
if
(
stats
->
tabentry
==
NULL
)
return
;
}
((
PgStat_TableEntry
*
)(
stats
->
tabentry
))
->
t_blocks_hit
++
;
}
/* ----------
* pgstat_count_xact_commit() -
*
...
...
src/include/pgstat.h
View file @
1d4ee0cc
...
...
@@ -5,7 +5,7 @@
*
* Copyright (c) 2001, PostgreSQL Global Development Group
*
* $Id: pgstat.h,v 1.
1 2001/06/22 19:18:36
wieck Exp $
* $Id: pgstat.h,v 1.
2 2001/06/29 16:29:37
wieck Exp $
* ----------
*/
#ifndef PGSTAT_H
...
...
@@ -347,22 +347,65 @@ extern void pgstat_reset_counters(void);
extern
void
pgstat_initstats
(
PgStat_Info
*
stats
,
Relation
rel
);
extern
void
pgstat_reset_heap_scan
(
PgStat_Info
*
stats
);
extern
void
pgstat_count_heap_scan
(
PgStat_Info
*
stats
);
extern
void
pgstat_count_heap_getnext
(
PgStat_Info
*
stats
);
extern
void
pgstat_count_heap_fetch
(
PgStat_Info
*
stats
);
extern
void
pgstat_count_heap_insert
(
PgStat_Info
*
stats
);
extern
void
pgstat_count_heap_update
(
PgStat_Info
*
stats
);
extern
void
pgstat_count_heap_delete
(
PgStat_Info
*
stats
);
extern
void
pgstat_reset_index_scan
(
PgStat_Info
*
stats
);
extern
void
pgstat_count_index_scan
(
PgStat_Info
*
stats
);
extern
void
pgstat_count_index_getnext
(
PgStat_Info
*
stats
);
extern
void
pgstat_count_buffer_read
(
PgStat_Info
*
stats
,
Relation
rel
);
extern
void
pgstat_count_buffer_hit
(
PgStat_Info
*
stats
,
Relation
rel
);
#define pgstat_reset_heap_scan(s) \
if ((s)->tabentry != NULL) \
(s)->heap_scan_counted = FALSE
#define pgstat_count_heap_scan(s) \
if ((s)->tabentry != NULL && !(s)->heap_scan_counted) { \
((PgStat_TableEntry *)((s)->tabentry))->t_numscans++; \
(s)->heap_scan_counted = TRUE; \
}
#define pgstat_count_heap_getnext(s) \
if ((s)->tabentry != NULL) \
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_returned++
#define pgstat_count_heap_fetch(s) \
if ((s)->tabentry != NULL) \
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_fetched++
#define pgstat_count_heap_insert(s) \
if ((s)->tabentry != NULL) \
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_inserted++
#define pgstat_count_heap_update(s) \
if ((s)->tabentry != NULL) \
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_updated++
#define pgstat_count_heap_delete(s) \
if ((s)->tabentry != NULL) \
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_deleted++
#define pgstat_reset_index_scan(s) \
if ((s)->tabentry != NULL) \
(s)->index_scan_counted = FALSE
#define pgstat_count_index_scan(s) \
if ((s)->tabentry != NULL && !(s)->index_scan_counted) { \
((PgStat_TableEntry *)((s)->tabentry))->t_numscans++; \
(s)->index_scan_counted = TRUE; \
}
#define pgstat_count_index_getnext(s) \
if ((s)->tabentry != NULL) \
((PgStat_TableEntry *)((s)->tabentry))->t_tuples_returned++
#define pgstat_count_buffer_read(s,r) \
if ((s)->tabentry != NULL) \
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_fetched++; \
else { \
if (!(s)->no_stats) { \
pgstat_initstats((s), (r)); \
if ((s)->tabentry != NULL) \
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_fetched++; \
} \
}
#define pgstat_count_buffer_hit(s,r) \
if ((s)->tabentry != NULL) \
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_hit++; \
else { \
if (!(s)->no_stats) { \
pgstat_initstats((s), (r)); \
if ((s)->tabentry != NULL) \
((PgStat_TableEntry *)((s)->tabentry))->t_blocks_hit++; \
} \
}
extern
void
pgstat_count_xact_commit
(
void
);
extern
void
pgstat_count_xact_rollback
(
void
);
...
...
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