8000 Statistical system views (yet without the config stuff, but · postgrespro/postgres_cluster@8d80b0d · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d80b0d

Browse files
Jan WieckJan Wieck
authored andcommitted
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
1 parent 7d6e281 commit 8d80b0d

File tree

34 files changed

+537
-98
lines changed
  • catalog
  • utils
  • test/regress/expected
  • 34 files changed

    +537
    -98
    lines changed

    src/backend/access/heap/heapam.c

    Lines changed: 34 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,7 +8,7 @@
    88
    *
    99
    *
    1010
    * IDENTIFICATION
    11-
    * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.118 2001/06/09 18:16:55 tgl Exp $
    11+
    * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.119 2001/06/22 19:16:20 wieck Exp $
    1212
    *
    1313
    *
    1414
    * INTERFACE ROUTINES
    @@ -45,6 +45,7 @@
    4545
    #include "miscadmin.h"
    4646
    #include "utils/inval.h"
    4747
    #include "utils/relcache.h"
    48+
    #include "pgstat.h"
    4849

    4950

    5051
    XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf, ItemPointerData from,
    @@ -531,6 +532,10 @@ heap_openr(const char *relationName, LOCKMODE lockmode)
    531532
    if (lockmode != NoLock)
    532533
    LockRelation(r, lockmode);
    533534

    535+
    pgstat_initstats(&r->pgstat_info, r);
    536+
    537+
    pgstat_initstats(&r->pgstat_info, r);
    538+
    534539
    return r;
    535540
    }
    536541

    @@ -591,6 +596,12 @@ heap_openr_nofail(const char *relationName)
    591596
    if (RelationIsValid(r) && r->rd_rel->relkind == RELKIND_INDEX)
    592597
    elog(ERROR, "%s is an index relation", RelationGetRelationName(r));
    593598

    599+
    if (RelationIsValid(r))
    600+
    pgstat_initstats(&r->pgstat_info, r);
    601+
    602+
    if (RelationIsValid(r))
    603+
    pgstat_initstats(&r->pgstat_info, r);
    604+
    594605
    return r;
    595606
    }
    596607

    @@ -668,6 +679,8 @@ heap_beginscan(Relation relation,
    668679
    scan->rs_snapshot = snapshot;
    669680
    scan->rs_nkeys = (short) nkeys;
    670681

    682+
    pgstat_initstats(&scan->rs_pgstat_info, relation);
    683+
    671684
    /*
    672685
    * we do this here instead of in initscan() because heap_rescan also
    673686
    * calls initscan() and we don't want to allocate memory again
    @@ -707,6 +720,8 @@ heap_rescan(HeapScanDesc scan,
    707720
    * reinitialize scan descriptor
    708721
    */
    709722
    initscan(scan, scan->rs_rd, scanFromEnd, scan->rs_nkeys, key);
    723+
    724+
    pgstat_reset_heap_scan(&scan->rs_pgstat_info);
    710725
    }
    711726

    712727
    /* ----------------
    @@ -828,13 +843,18 @@ heap_getnext(HeapScanDesc scan, int backw)
    828843
    }
    829844
    }
    830845

    846+
    pgstat_count_heap_scan(&scan->rs_pgstat_info);
    847+
    831848
    /*
    832849
    * if we get here it means we have a new current scan tuple, so point
    833850
    * to the proper return buffer and return the tuple.
    834851
    */
    835852

    836853
    HEAPDEBUG_3; /* heap_getnext returning tuple */
    837854

    855+
    if (scan->rs_ctup.t_data != NULL)
    856+
    pgstat_count_heap_getnext(&scan->rs_pgstat_info);
    857+
    838858
    return ((scan->rs_ctup.t_data == NULL) ? NULL : &(scan->rs_ctup));
    839859
    }
    840860

    @@ -855,7 +875,8 @@ void
    855875
    heap_fetch(Relation relation,
    856876
    Snapshot snapshot,
    857877
    HeapTuple tuple,
    858-
    Buffer *userbuf)
    878+
    Buffer *userbuf,
    879+
    IndexScanDesc iscan)
    859880
    {
    860881
    ItemId lp;
    861882
    Buffer buffer;
    @@ -930,6 +951,11 @@ heap_fetch(Relation relation,
    930951
    * responsible for releasing the buffer.
    931952
    */
    932953
    *userbuf = buffer;
    954+
    955+
    if (iscan != NULL)
    956+
    pgstat_count_heap_fetch(&iscan->xs_pgstat_info);
    957+
    else
    958+
    pgstat_count_heap_fetch(&relation->pgstat_info);
    933959
    }
    934960
    }
    935961

    @@ -1081,6 +1107,8 @@ heap_insert(Relation relation, HeapTuple tup)
    10811107
    START_CRIT_SECTION();
    10821108
    RelationPutHeapTuple(relation, buffer, tup);
    10831109

    1110+
    pgstat_count_heap_insert(&relation->pgstat_info);
    1111+
    10841112
    /* XLOG stuff */
    10851113
    {
    10861114
    xl_heap_insert xlrec;
    @@ -1269,6 +1297,8 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
    12691297
    heap_tuple_toast_attrs(relation, NULL, &(tp));
    12701298
    #endif
    12711299

    1300+
    pgstat_count_heap_delete(&relation->pgstat_info);
    1301+
    12721302
    /*
    12731303
    * Mark tuple for invalidation from system caches at next command
    12741304
    * boundary. We have to do this before WriteBuffer because we need to
    @@ -1528,6 +1558,8 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
    15281558
    newbuf = buffer;
    15291559
    }
    15301560

    1561+
    pgstat_count_heap_update(&relation->pgstat_info);
    1562+
    15311563
    /*
    15321564
    * At this point newbuf and buffer are both pinned and locked,
    15331565
    * and newbuf has enough space for the new tuple.

    src/backend/access/heap/tuptoaster.c

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,7 +8,7 @@
    88
    *
    99
    *
    1010
    * IDENTIFICATION
    11-
    * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.22 2001/05/07 00:43:15 tgl Exp $
    11+
    * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.23 2001/06/22 19:16:20 wieck Exp $
    1212
    *
    1313
    *
    1414
    * INTERFACE ROUTINES
    @@ -936,7 +936,7 @@ toast_delete_datum(Relation rel, Datum value)
    936936
    while ((indexRes = index_getnext(toastscan, ForwardScanDirection)) != NULL)
    937937
    {
    938938
    toasttup.t_self = indexRes->heap_iptr;
    939-
    heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer);
    939+
    heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer, toastscan);
    940940
    pfree(indexRes);
    941941

    942942
    if (!toasttup.t_data)
    @@ -1029,7 +1029,7 @@ toast_fetch_datum(varattrib *attr)
    10291029
    while ((indexRes = index_getnext(toastscan, ForwardScanDirection)) != NULL)
    10301030
    {
    10311031
    toasttup.t_self = indexRes->heap_iptr;
    1032-
    heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer);
    1032+
    heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer, toastscan);
    10331033
    pfree(indexRes);
    10341034

    10351035
    if (toasttup.t_data == NULL)

    src/backend/access/index/genam.c

    Lines changed: 4 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -8,7 +8,7 @@
    88
    *
    99
    *
    1010
    * IDENTIFICATION
    11-
    * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.27 2001/06/09 18:16:56 tgl Exp $
    11+
    * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.28 2001/06/22 19:16:21 wieck Exp $
    1212
    *
    1313
    * NOTES
    1414
    * many of the old access method routines have been turned into
    @@ -48,6 +48,7 @@
    4848
    #include "postgres.h"
    4949
    #include "access/genam.h"
    5050

    51+
    #include "pgstat.h"
    5152

    5253
    /* ----------------------------------------------------------------
    5354
    * general access method routines
    @@ -110,6 +111,8 @@ RelationGetIndexScan(Relation relation,
    110111
    ItemPointerSetInvalid(&scan->currentItemData);
    111112
    ItemPointerSetInvalid(&scan->currentMarkData);
    112113

    114+
    pgstat_initstats(&scan->xs_pgstat_info, relation);
    115+
    113116
    /*
    114117
    * mark cached function lookup data invalid; it will be set on first
    115118
    * use

    src/backend/access/index/indexam.c

    Lines changed: 14 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -8,7 +8,7 @@
    88
    *
    99
    *
    1010
    * IDENTIFICATION
    11-
    * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.50 2001/06/01 02:41:35 tgl Exp $
    11+
    * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.51 2001/06/22 19:16:21 wieck Exp $
    1212
    *
    1313
    * INTERFACE ROUTINES
    1414
    * index_open - open an index relation by relationId
    @@ -70,6 +70,7 @@
    7070
    #include "access/heapam.h"
    7171
    #include "utils/relcache.h"
    7272

    73+
    #include "pgstat.h"
    7374

    7475
    /* ----------------------------------------------------------------
    7576
    * macros used in index_ routines
    @@ -135,6 +136,8 @@ index_open(Oid relationId)
    135136
    if (r->rd_rel->relkind != RELKIND_INDEX)
    136137
    elog(ERROR, "%s is not an index relation", RelationGetRelationName(r));
    137138

    139+
    pgstat_initstats(&r->pgstat_info, r);
    140+
    138141
    return r;
    139142
    }
    140143

    @@ -157,6 +160,8 @@ index_openr(char *relationName)
    157160
    if (r->rd_rel->relkind != RELKIND_INDEX)
    158161
    elog(ERROR, "%s is not an index relation", RelationGetRelationName(r));
    159162

    163+
    pgstat_initstats(&r->pgstat_info, r);
    164+
    160165
    return r;
    161166
    }
    162167

    @@ -256,6 +261,8 @@ index_beginscan(Relation relation,
    256261
    UInt16GetDatum(numberOfKeys),
    257262
    PointerGetDatum(key)));
    258263

    264+
    pgstat_initstats(&scan->xs_pgstat_info, relation);
    265+
    259266
    /*
    260267
    * We want to look up the amgettuple procedure just once per scan,
    261268
    * not once per index_getnext call. So do it here and save
    @@ -283,6 +290,8 @@ index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key)
    283290
    PointerGetDatum(scan),
    284291
    BoolGetDatum(scanFromEnd),
    285292
    PointerGetDatum(key));
    293+
    294+
    pgstat_reset_index_scan(&scan->xs_pgstat_info);
    286295
    }
    287296

    288297
    /* ----------------
    @@ -353,6 +362,8 @@ index_getnext(IndexScanDesc scan,
    353362

    354363
    SCAN_CHECKS;
    355364

    365+
    pgstat_count_index_scan(&scan->xs_pgstat_info);
    366+
    356367
    /*
    357368
    * have the am's gettuple proc do all the work.
    358369
    * index_beginscan already set up fn_getnext.
    @@ -362,6 +373,8 @@ index_getnext(IndexScanDesc scan,
    362373
    PointerGetDatum(scan),
    363374
    Int32GetDatum(direction)));
    364375

    376+
    if (result != NULL)
    377+
    pgstat_count_index_getnext(&scan->xs_pgstat_info);
    365378
    return result;
    366379
    }
    367380

    src/backend/access/nbtree/nbtinsert.c

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,7 +8,7 @@
    88
    *
    99
    *
    1010
    * IDENTIFICATION
    11-
    * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.82 2001/03/22 03:59:14 momjian Exp $
    11+
    * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.83 2001/06/22 19:16:21 wieck Exp $
    1212
    *
    1313
    *-------------------------------------------------------------------------
    1414
    */
    @@ -209,7 +209,7 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
    209209
    if (chtup)
    210210
    {
    211211
    htup.t_self = btitem->bti_itup.t_tid;
    212-
    heap_fetch(heapRel, SnapshotDirty, &htup, &buffer);
    212+
    heap_fetch(heapRel, SnapshotDirty, &htup, &buffer, NULL);
    213213
    if (htup.t_data == NULL) /* YES! */
    214214
    break;
    215215
    /* Live tuple is being inserted, so continue checking */
    @@ -219,7 +219,7 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
    219219

    220220
    cbti = (BTItem) PageGetItem(page, PageGetItemId(page, offset));
    221221
    htup.t_self = cbti->bti_itup.t_tid;
    222-
    heap_fetch(heapRel, SnapshotDirty, &htup, &buffer);
    222+
    heap_fetch(heapRel, SnapshotDirty, &htup, &buffer, NULL);
    223223
    if (htup.t_data != NULL) /* it is a duplicate */
    224224
    {
    225225
    TransactionId xwait =

    src/backend/access/transam/xact.c

    Lines changed: 9 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -8,7 +8,7 @@
    88
    *
    99
    *
    1010
    * IDENTIFICATION
    11-
    * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.103 2001/06/19 19:42:15 tgl Exp $
    11+
    * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.104 2001/06/22 19:16:21 wieck Exp $
    1212
    *
    1313
    * NOTES
    1414
    * Transaction aborts can now occur two ways:
    @@ -176,6 +176,8 @@
    176176
    #include "utils/relcache.h"
    177177
    #include "utils/temprel.h"
    178178

    179+
    #include "pgstat.h"
    180+
    179181
    extern bool SharedBufferChanged;
    180182

    181183
    static void AbortTransaction(void);
    @@ -1083,6 +1085,9 @@ CommitTransaction(void)
    10831085

    10841086
    SharedBufferChanged = false;/* safest place to do it */
    10851087

    1088+
    /* Count transaction commit in statistics collector */
    1089+
    pgstat_count_xact_commit();
    1090+
    10861091
    /*
    10871092
    * done with commit processing, set current transaction state back to
    10881093
    * default
    @@ -1163,6 +1168,9 @@ AbortTransaction(void)
    11631168
    AtEOXact_portals();
    11641169
    RecordTransactionAbort();
    11651170

    1171+
    /* Count transaction abort in statistics collector */
    1172+
    pgstat_count_xact_rollback();
    1173+
    11661174
    RelationPurgeLocalRelation(false);
    11671175
    AtEOXact_temp_relations(false);
    11681176
    smgrDoPendingDeletes(false);

    src/backend/catalog/indexing.c

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -9,7 +9,7 @@
    99
    *
    1010
    *
    1111
    * IDENTIFICATION
    12-
    * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.79 2001/06/16 18:59:31 tgl Exp $
    12+
    * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.80 2001/06/22 19:16:21 wieck Exp $
    1313
    *
    1414
    *-------------------------------------------------------------------------
    1515
    */
    @@ -206,7 +206,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
    206206
    while ((indexRes = index_getnext(sd, ForwardScanDirection)))
    207207
    {
    208208
    tuple.t_self = indexRes->heap_iptr;
    209-
    heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer);
    209+
    heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer, sd);
    210210
    pfree(indexRes);
    211211
    if (tuple.t_data != NULL)
    212212
    break;

    src/backend/catalog/pg_largeobject.c

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,7 +8,7 @@
    88
    *
    99
    *
    1010
    * IDENTIFICATION
    11-
    * $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.8 2001/03/22 03:59:20 momjian Exp $
    11+
    * $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.9 2001/06/22 19:16:21 wieck Exp $
    1212
    *
    1313
    *-------------------------------------------------------------------------
    1414
    */
    @@ -114,7 +114,7 @@ LargeObjectDrop(Oid loid)
    114114
    while ((indexRes = index_getnext(sd, ForwardScanDirection)))
    115115
    {
    116116
    tuple.t_self = indexRes->heap_iptr;
    117-
    heap_fetch(pg_largeobject, SnapshotNow, &tuple, &buffer);
    117+
    heap_fetch(pg_largeobject, SnapshotNow, &tuple, &buffer, sd);
    118118
    pfree(indexRes);
    119119
    if (tuple.t_data != NULL)
    120120
    {
    @@ -165,7 +165,7 @@ LargeObjectExists(Oid loid)
    165165
    while ((indexRes = index_getnext(sd, ForwardScanDirection)))
    166166
    {
    167167
    tuple.t_self = indexRes->heap_iptr;
    168-
    heap_fetch(pg_largeobject, SnapshotNow, &tuple, &buffer);
    168+
    heap_fetch(pg_largeobject, SnapshotNow, &tuple, &buffer, sd);
    169169
    pfree(indexRes);
    170170
    if (tuple.t_data != NULL)
    171171
    {

    src/backend/commands/analyze.c

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,7 +8,7 @@
    88
    *
    99
    *
    1010
    * IDENTIFICATION
    11-
    * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.20 2001/06/13 21:44:40 tgl Exp $
    11+
    * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.21 2001/06/22 19:16:21 wieck Exp $
    1212
    *
    1313
    *-------------------------------------------------------------------------
    1414
    */
    @@ -609,7 +609,7 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows,
    609609
    goto pageloop;
    610610
    }
    611611
    ItemPointerSet(&targtuple.t_self, targblock, targoffset);
    612-
    heap_fetch(onerel, SnapshotNow, &targtuple, &targbuffer);
    612+
    heap_fetch(onerel, SnapshotNow, &targtuple, &targbuffer, NULL);
    613613
    if (targtuple.t_data != NULL)
    614614
    {
    615615
    /*

    src/backend/commands/cluster.c

    Lines changed: 3 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -15,7 +15,7 @@
    1515
    *
    1616
    *
    1717
    * IDENTIFICATION
    18-
    * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.65 2001/03/22 03:59:21 momjian Exp $
    18+
    * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.66 2001/06/22 19:16:21 wieck Exp $
    1919
    *
    2020
    *-------------------------------------------------------------------------
    2121
    */
    @@ -264,7 +264,8 @@ rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
    264264
    LocalHeapTuple.t_self = ScanResult->heap_iptr;
    265265
    LocalHeapTuple.t_datamcxt = NULL;
    266266
    LocalHeapTuple.t_data = NULL;
    267-
    heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer);
    267+
    heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer,
    268+
    ScanDesc);
    268269
    if (LocalHeapTuple.t_data != NULL)
    269270
    {
    270271

    0 commit comments

    Comments
     (0)
    0