|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * 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 $ |
12 | 12 | *
|
13 | 13 | *
|
14 | 14 | * INTERFACE ROUTINES
|
|
45 | 45 | #include"miscadmin.h"
|
46 | 46 | #include"utils/inval.h"
|
47 | 47 | #include"utils/relcache.h"
|
| 48 | +#include"pgstat.h" |
48 | 49 |
|
49 | 50 |
|
50 | 51 | XLogRecPtrlog_heap_move(Relationreln,Bufferoldbuf,ItemPointerDatafrom,
|
@@ -531,6 +532,10 @@ heap_openr(const char *relationName, LOCKMODE lockmode)
|
531 | 532 | if (lockmode!=NoLock)
|
532 | 533 | LockRelation(r,lockmode);
|
533 | 534 |
|
| 535 | +pgstat_initstats(&r->pgstat_info,r); |
| 536 | + |
| 537 | +pgstat_initstats(&r->pgstat_info,r); |
| 538 | + |
534 | 539 | returnr;
|
535 | 540 | }
|
536 | 541 |
|
@@ -591,6 +596,12 @@ heap_openr_nofail(const char *relationName)
|
591 | 596 | if (RelationIsValid(r)&&r->rd_rel->relkind==RELKIND_INDEX)
|
592 | 597 | elog(ERROR,"%s is an index relation",RelationGetRelationName(r));
|
593 | 598 |
|
| 599 | +if (RelationIsValid(r)) |
| 600 | +pgstat_initstats(&r->pgstat_info,r); |
| 601 | + |
| 602 | +if (RelationIsValid(r)) |
| 603 | +pgstat_initstats(&r->pgstat_info,r); |
| 604 | + |
594 | 605 | returnr;
|
595 | 606 | }
|
596 | 607 |
|
@@ -668,6 +679,8 @@ heap_beginscan(Relation relation,
|
668 | 679 | scan->rs_snapshot=snapshot;
|
669 | 680 | scan->rs_nkeys= (short)nkeys;
|
670 | 681 |
|
| 682 | +pgstat_initstats(&scan->rs_pgstat_info,relation); |
| 683 | + |
671 | 684 | /*
|
672 | 685 | * we do this here instead of in initscan() because heap_rescan also
|
673 | 686 | * calls initscan() and we don't want to allocate memory again
|
@@ -707,6 +720,8 @@ heap_rescan(HeapScanDesc scan,
|
707 | 720 | * reinitialize scan descriptor
|
708 | 721 | */
|
709 | 722 | initscan(scan,scan->rs_rd,scanFromEnd,scan->rs_nkeys,key);
|
| 723 | + |
| 724 | +pgstat_reset_heap_scan(&scan->rs_pgstat_info); |
710 | 725 | }
|
711 | 726 |
|
712 | 727 | /* ----------------
|
@@ -828,13 +843,18 @@ heap_getnext(HeapScanDesc scan, int backw)
|
828 | 843 | }
|
829 | 844 | }
|
830 | 845 |
|
| 846 | +pgstat_count_heap_scan(&scan->rs_pgstat_info); |
| 847 | + |
831 | 848 | /*
|
832 | 849 | * if we get here it means we have a new current scan tuple, so point
|
833 | 850 | * to the proper return buffer and return the tuple.
|
834 | 851 | */
|
835 | 852 |
|
836 | 853 | HEAPDEBUG_3;/* heap_getnext returning tuple */
|
837 | 854 |
|
| 855 | +if (scan->rs_ctup.t_data!=NULL) |
| 856 | +pgstat_count_heap_getnext(&scan->rs_pgstat_info); |
| 857 | + |
838 | 858 | return ((scan->rs_ctup.t_data==NULL) ?NULL :&(scan->rs_ctup));
|
839 | 859 | }
|
840 | 860 |
|
|
855 | 875 | heap_fetch(Relationrelation,
|
856 | 876 | Snapshotsnapshot,
|
857 | 877 | HeapTupletuple,
|
858 |
| -Buffer*userbuf) |
| 878 | +Buffer*userbuf, |
| 879 | +IndexScanDesciscan) |
859 | 880 | {
|
860 | 881 | ItemIdlp;
|
861 | 882 | Bufferbuffer;
|
@@ -930,6 +951,11 @@ heap_fetch(Relation relation,
|
930 | 951 | * responsible for releasing the buffer.
|
931 | 952 | */
|
932 | 953 | *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); |
933 | 959 | }
|
934 | 960 | }
|
935 | 961 |
|
@@ -1081,6 +1107,8 @@ heap_insert(Relation relation, HeapTuple tup)
|
1081 | 1107 | START_CRIT_SECTION();
|
1082 | 1108 | RelationPutHeapTuple(relation,buffer,tup);
|
1083 | 1109 |
|
| 1110 | +pgstat_count_heap_insert(&relation->pgstat_info); |
| 1111 | + |
1084 | 1112 | /* XLOG stuff */
|
1085 | 1113 | {
|
1086 | 1114 | xl_heap_insertxlrec;
|
@@ -1269,6 +1297,8 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
|
1269 | 1297 | heap_tuple_toast_attrs(relation,NULL,&(tp));
|
1270 | 1298 | #endif
|
1271 | 1299 |
|
| 1300 | +pgstat_count_heap_delete(&relation->pgstat_info); |
| 1301 | + |
1272 | 1302 | /*
|
1273 | 1303 | * Mark tuple for invalidation from system caches at next command
|
1274 | 1304 | * boundary. We have to do this before WriteBuffer because we need to
|
@@ -1528,6 +1558,8 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
|
1528 | 1558 | newbuf=buffer;
|
1529 | 1559 | }
|
1530 | 1560 |
|
| 1561 | +pgstat_count_heap_update(&relation->pgstat_info); |
| 1562 | + |
1531 | 1563 | /*
|
1532 | 1564 | * At this point newbuf and buffer are both pinned and locked,
|
1533 | 1565 | * and newbuf has enough space for the new tuple.
|
|