Skip to content

Commit 538f58c

Browse files
committed
#ifdef BTREE_BUILD_STATS enables to get executor stats for btree
building.
1 parent d94c7fc commit 538f58c

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

src/backend/access/nbtree/nbtree.c

Lines changed: 18 additions & 14 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/nbtree.c,v 1.17 1997/03/24 08:48:11 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.18 1997/04/18 03:37:53 vadim Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -33,6 +33,12 @@
3333
# include <string.h>
3434
#endif
3535

36+
#ifdef BTREE_BUILD_STATS
37+
#include <tcop/tcopprot.h>
38+
extern int ShowExecutorStats;
39+
#endif
40+
41+
3642
bool BuildingBtree = false; /* see comment in btbuild() */
3743
bool FastBuild = true; /* use sort/build instead of insertion build */
3844

@@ -77,10 +83,6 @@ btbuild(Relation heap,
7783
bool isunique;
7884
bool usefast;
7985

80-
#if 0
81-
ResetBufferUsage();
82-
#endif
83-
8486
/* note that this is a new btree */
8587
BuildingBtree = true;
8688

@@ -95,6 +97,11 @@ btbuild(Relation heap,
9597
*/
9698
usefast = (FastBuild && IsNormalProcessingMode());
9799

100+
#ifdef BTREE_BUILD_STATS
101+
if ( ShowExecutorStats )
102+
ResetUsage ();
103+
#endif
104+
98105
/* see if index is unique */
99106
isunique = IndexIsUniqueNoCache(RelationGetRelationId(index));
100107

@@ -278,18 +285,15 @@ btbuild(Relation heap,
278285
_bt_spooldestroy(spool);
279286
}
280287

281-
#if 0
288+
#ifdef BTREE_BUILD_STATS
289+
if ( ShowExecutorStats )
282290
{
283-
extern int ReadBufferCount, BufferHitCount, BufferFlushCount;
284-
extern long NDirectFileRead, NDirectFileWrite;
285-
286-
printf("buffer(%d): r=%d w=%d\n", heap->rd_rel->relblocksz,
287-
ReadBufferCount - BufferHitCount, BufferFlushCount);
288-
printf("direct(%d): r=%d w=%d\n", LocalBlockSize,
289-
NDirectFileRead, NDirectFileWrite);
291+
fprintf(stderr, "! BtreeBuild Stats:\n");
292+
ShowUsage ();
293+
ResetUsage ();
290294
}
291295
#endif
292-
296+
293297
/*
294298
* Since we just counted the tuples in the heap, we update its
295299
* stats in pg_class to guarantee that the planner takes advantage

src/backend/access/nbtree/nbtsort.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*
77
* IDENTIFICATION
8-
* $Id: nbtsort.c,v 1.14 1997/04/16 01:48:27 vadim Exp $
8+
* $Id: nbtsort.c,v 1.15 1997/04/18 03:37:57 vadim Exp $
99
*
1010
* NOTES
1111
*
@@ -63,6 +63,11 @@
6363
# include <string.h>
6464
#endif
6565

66+
#ifdef BTREE_BUILD_STATS
67+
#include <tcop/tcopprot.h>
68+
extern int ShowExecutorStats;
69+
#endif
70+
6671
/*
6772
* turn on debugging output.
6873
*
@@ -427,7 +432,7 @@ _bt_tapewrite(BTTapeBlock *tape, int eor)
427432
{
428433
tape->bttb_eor = eor;
429434
FileWrite(tape->bttb_fd, (char *) tape, TAPEBLCKSZ);
430-
NDirectFileWrite += TAPEBLCKSZ;
435+
NDirectFileWrite += TAPEBLCKSZ/MAXBLCKSZ;
431436
_bt_tapereset(tape);
432437
}
433438

@@ -463,7 +468,7 @@ _bt_taperead(BTTapeBlock *tape)
463468
return(0);
464469
}
465470
Assert(tape->bttb_magic == BTTAPEMAGIC);
466-
NDirectFileRead += TAPEBLCKSZ;
471+
NDirectFileRead += TAPEBLCKSZ/MAXBLCKSZ;
467472
return(1);
468473
}
469474

@@ -1366,5 +1371,16 @@ void
13661371
_bt_leafbuild(Relation index, void *spool)
13671372
{
13681373
_bt_isortcmpinit (index, (BTSpool *) spool);
1374+
1375+
#ifdef BTREE_BUILD_STATS
1376+
if ( ShowExecutorStats )
1377+
{
1378+
fprintf(stderr, "! BtreeBuild (Spool) Stats:\n");
1379+
ShowUsage ();
1380+
ResetUsage ();
1381+
}
1382+
#endif
1383+
13691384
_bt_merge(index, (BTSpool *) spool);
1385+
13701386
}

0 commit comments

Comments
 (0)