mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Statistical system views (yet without the config stuff, but
it's hard to keep such massive changes in sync with the tree so I need to get it in and work from there now). Jan
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.118 2001/06/09 18:16:55 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.119 2001/06/22 19:16:20 wieck Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -45,6 +45,7 @@
|
||||
#include "miscadmin.h"
|
||||
#include "utils/inval.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "pgstat.h"
|
||||
|
||||
|
||||
XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf, ItemPointerData from,
|
||||
@ -531,6 +532,10 @@ heap_openr(const char *relationName, LOCKMODE lockmode)
|
||||
if (lockmode != NoLock)
|
||||
LockRelation(r, lockmode);
|
||||
|
||||
pgstat_initstats(&r->pgstat_info, r);
|
||||
|
||||
pgstat_initstats(&r->pgstat_info, r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -591,6 +596,12 @@ heap_openr_nofail(const char *relationName)
|
||||
if (RelationIsValid(r) && r->rd_rel->relkind == RELKIND_INDEX)
|
||||
elog(ERROR, "%s is an index relation", RelationGetRelationName(r));
|
||||
|
||||
if (RelationIsValid(r))
|
||||
pgstat_initstats(&r->pgstat_info, r);
|
||||
|
||||
if (RelationIsValid(r))
|
||||
pgstat_initstats(&r->pgstat_info, r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -668,6 +679,8 @@ heap_beginscan(Relation relation,
|
||||
scan->rs_snapshot = snapshot;
|
||||
scan->rs_nkeys = (short) nkeys;
|
||||
|
||||
pgstat_initstats(&scan->rs_pgstat_info, relation);
|
||||
|
||||
/*
|
||||
* we do this here instead of in initscan() because heap_rescan also
|
||||
* calls initscan() and we don't want to allocate memory again
|
||||
@ -707,6 +720,8 @@ heap_rescan(HeapScanDesc scan,
|
||||
* reinitialize scan descriptor
|
||||
*/
|
||||
initscan(scan, scan->rs_rd, scanFromEnd, scan->rs_nkeys, key);
|
||||
|
||||
pgstat_reset_heap_scan(&scan->rs_pgstat_info);
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
@ -828,6 +843,8 @@ heap_getnext(HeapScanDesc scan, int backw)
|
||||
}
|
||||
}
|
||||
|
||||
pgstat_count_heap_scan(&scan->rs_pgstat_info);
|
||||
|
||||
/*
|
||||
* if we get here it means we have a new current scan tuple, so point
|
||||
* to the proper return buffer and return the tuple.
|
||||
@ -835,6 +852,9 @@ heap_getnext(HeapScanDesc scan, int backw)
|
||||
|
||||
HEAPDEBUG_3; /* heap_getnext returning tuple */
|
||||
|
||||
if (scan->rs_ctup.t_data != NULL)
|
||||
pgstat_count_heap_getnext(&scan->rs_pgstat_info);
|
||||
|
||||
return ((scan->rs_ctup.t_data == NULL) ? NULL : &(scan->rs_ctup));
|
||||
}
|
||||
|
||||
@ -855,7 +875,8 @@ void
|
||||
heap_fetch(Relation relation,
|
||||
Snapshot snapshot,
|
||||
HeapTuple tuple,
|
||||
Buffer *userbuf)
|
||||
Buffer *userbuf,
|
||||
IndexScanDesc iscan)
|
||||
{
|
||||
ItemId lp;
|
||||
Buffer buffer;
|
||||
@ -930,6 +951,11 @@ heap_fetch(Relation relation,
|
||||
* responsible for releasing the buffer.
|
||||
*/
|
||||
*userbuf = buffer;
|
||||
|
||||
if (iscan != NULL)
|
||||
pgstat_count_heap_fetch(&iscan->xs_pgstat_info);
|
||||
else
|
||||
pgstat_count_heap_fetch(&relation->pgstat_info);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1081,6 +1107,8 @@ heap_insert(Relation relation, HeapTuple tup)
|
||||
START_CRIT_SECTION();
|
||||
RelationPutHeapTuple(relation, buffer, tup);
|
||||
|
||||
pgstat_count_heap_insert(&relation->pgstat_info);
|
||||
|
||||
/* XLOG stuff */
|
||||
{
|
||||
xl_heap_insert xlrec;
|
||||
@ -1269,6 +1297,8 @@ l1:
|
||||
heap_tuple_toast_attrs(relation, NULL, &(tp));
|
||||
#endif
|
||||
|
||||
pgstat_count_heap_delete(&relation->pgstat_info);
|
||||
|
||||
/*
|
||||
* Mark tuple for invalidation from system caches at next command
|
||||
* boundary. We have to do this before WriteBuffer because we need to
|
||||
@ -1528,6 +1558,8 @@ l2:
|
||||
newbuf = buffer;
|
||||
}
|
||||
|
||||
pgstat_count_heap_update(&relation->pgstat_info);
|
||||
|
||||
/*
|
||||
* At this point newbuf and buffer are both pinned and locked,
|
||||
* and newbuf has enough space for the new tuple.
|
||||
|
Reference in New Issue
Block a user