1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +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:
Jan Wieck
2001-06-22 19:16:24 +00:00
parent 7d6e28149e
commit 8d80b0d980
34 changed files with 537 additions and 98 deletions

View File

@@ -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.

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.22 2001/05/07 00:43:15 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.23 2001/06/22 19:16:20 wieck Exp $
*
*
* INTERFACE ROUTINES
@@ -936,7 +936,7 @@ toast_delete_datum(Relation rel, Datum value)
while ((indexRes = index_getnext(toastscan, ForwardScanDirection)) != NULL)
{
toasttup.t_self = indexRes->heap_iptr;
heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer);
heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer, toastscan);
pfree(indexRes);
if (!toasttup.t_data)
@@ -1029,7 +1029,7 @@ toast_fetch_datum(varattrib *attr)
while ((indexRes = index_getnext(toastscan, ForwardScanDirection)) != NULL)
{
toasttup.t_self = indexRes->heap_iptr;
heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer);
heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer, toastscan);
pfree(indexRes);
if (toasttup.t_data == NULL)

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.27 2001/06/09 18:16:56 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.28 2001/06/22 19:16:21 wieck Exp $
*
* NOTES
* many of the old access method routines have been turned into
@@ -48,6 +48,7 @@
#include "postgres.h"
#include "access/genam.h"
#include "pgstat.h"
/* ----------------------------------------------------------------
* general access method routines
@@ -110,6 +111,8 @@ RelationGetIndexScan(Relation relation,
ItemPointerSetInvalid(&scan->currentItemData);
ItemPointerSetInvalid(&scan->currentMarkData);
pgstat_initstats(&scan->xs_pgstat_info, relation);
/*
* mark cached function lookup data invalid; it will be set on first
* use

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.50 2001/06/01 02:41:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.51 2001/06/22 19:16:21 wieck Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relationId
@@ -70,6 +70,7 @@
#include "access/heapam.h"
#include "utils/relcache.h"
#include "pgstat.h"
/* ----------------------------------------------------------------
* macros used in index_ routines
@@ -135,6 +136,8 @@ index_open(Oid relationId)
if (r->rd_rel->relkind != RELKIND_INDEX)
elog(ERROR, "%s is not an index relation", RelationGetRelationName(r));
pgstat_initstats(&r->pgstat_info, r);
return r;
}
@@ -157,6 +160,8 @@ index_openr(char *relationName)
if (r->rd_rel->relkind != RELKIND_INDEX)
elog(ERROR, "%s is not an index relation", RelationGetRelationName(r));
pgstat_initstats(&r->pgstat_info, r);
return r;
}
@@ -256,6 +261,8 @@ index_beginscan(Relation relation,
UInt16GetDatum(numberOfKeys),
PointerGetDatum(key)));
pgstat_initstats(&scan->xs_pgstat_info, relation);
/*
* We want to look up the amgettuple procedure just once per scan,
* not once per index_getnext call. So do it here and save
@@ -283,6 +290,8 @@ index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key)
PointerGetDatum(scan),
BoolGetDatum(scanFromEnd),
PointerGetDatum(key));
pgstat_reset_index_scan(&scan->xs_pgstat_info);
}
/* ----------------
@@ -353,6 +362,8 @@ index_getnext(IndexScanDesc scan,
SCAN_CHECKS;
pgstat_count_index_scan(&scan->xs_pgstat_info);
/*
* have the am's gettuple proc do all the work.
* index_beginscan already set up fn_getnext.
@@ -362,6 +373,8 @@ index_getnext(IndexScanDesc scan,
PointerGetDatum(scan),
Int32GetDatum(direction)));
if (result != NULL)
pgstat_count_index_getnext(&scan->xs_pgstat_info);
return result;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.82 2001/03/22 03:59:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.83 2001/06/22 19:16:21 wieck Exp $
*
*-------------------------------------------------------------------------
*/
@@ -209,7 +209,7 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
if (chtup)
{
htup.t_self = btitem->bti_itup.t_tid;
heap_fetch(heapRel, SnapshotDirty, &htup, &buffer);
heap_fetch(heapRel, SnapshotDirty, &htup, &buffer, NULL);
if (htup.t_data == NULL) /* YES! */
break;
/* Live tuple is being inserted, so continue checking */
@@ -219,7 +219,7 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
cbti = (BTItem) PageGetItem(page, PageGetItemId(page, offset));
htup.t_self = cbti->bti_itup.t_tid;
heap_fetch(heapRel, SnapshotDirty, &htup, &buffer);
heap_fetch(heapRel, SnapshotDirty, &htup, &buffer, NULL);
if (htup.t_data != NULL) /* it is a duplicate */
{
TransactionId xwait =

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.103 2001/06/19 19:42:15 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.104 2001/06/22 19:16:21 wieck Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@@ -176,6 +176,8 @@
#include "utils/relcache.h"
#include "utils/temprel.h"
#include "pgstat.h"
extern bool SharedBufferChanged;
static void AbortTransaction(void);
@@ -1083,6 +1085,9 @@ CommitTransaction(void)
SharedBufferChanged = false;/* safest place to do it */
/* Count transaction commit in statistics collector */
pgstat_count_xact_commit();
/*
* done with commit processing, set current transaction state back to
* default
@@ -1163,6 +1168,9 @@ AbortTransaction(void)
AtEOXact_portals();
RecordTransactionAbort();
/* Count transaction abort in statistics collector */
pgstat_count_xact_rollback();
RelationPurgeLocalRelation(false);
AtEOXact_temp_relations(false);
smgrDoPendingDeletes(false);