Skip to content

Commit 922e53e

Browse files
committed
Enable pg_statistic cache use.
1 parent 8f401e8 commit 922e53e

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

src/backend/catalog/indexing.c

Lines changed: 3 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/catalog/indexing.c,v 1.52 1999/11/24 16:52:31 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.53 1999/11/25 00:15:56 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -63,6 +63,8 @@ char *Name_pg_rewrite_indices[Num_pg_rewrite_indices] =
6363
{RewriteOidIndex, RewriteRulenameIndex};
6464
char *Name_pg_shadow_indices[Num_pg_shadow_indices] =
6565
{ShadowNameIndex, ShadowSysidIndex};
66+
char *Name_pg_statistic_indices[Num_pg_statistic_indices] =
67+
{StatisticRelidAttnumOpIndex};
6668
char *Name_pg_trigger_indices[Num_pg_trigger_indices] =
6769
{TriggerRelidIndex, TriggerConstrNameIndex, TriggerConstrRelidIndex};
6870
char *Name_pg_type_indices[Num_pg_type_indices] =

src/backend/commands/rename.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.36 1999/11/24 00:44:30 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.37 1999/11/25 00:15:57 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -56,7 +56,6 @@ renameatt(char *relname,
5656
HeapTuple reltup,
5757
oldatttup,
5858
newatttup;
59-
Relation irelations[Num_pg_attr_indices];
6059
Oid relid;
6160

6261
/*
@@ -159,10 +158,13 @@ renameatt(char *relname,
159158
heap_update(attrelation, &oldatttup->t_self, oldatttup, NULL);
160159

161160
/* keep system catalog indices current */
162-
CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
163-
CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, oldatttup);
164-
CatalogCloseIndices(Num_pg_attr_indices, irelations);
165-
161+
{
162+
Relation irelations[Num_pg_attr_indices];
163+
CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
164+
CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, oldatttup);
165+
CatalogCloseIndices(Num_pg_attr_indices, irelations);
166+
}
167+
166168
pfree(oldatttup);
167169
heap_close(attrelation, RowExclusiveLock);
168170
}

src/backend/commands/vacuum.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.125 1999/11/22 17:56:02 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.126 1999/11/25 00:15:57 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -24,6 +24,7 @@
2424
#include "catalog/catalog.h"
2525
#include "catalog/catname.h"
2626
#include "catalog/index.h"
27+
#include "catalog/indexing.h"
2728
#include "catalog/pg_operator.h"
2829
#include "catalog/pg_statistic.h"
2930
#include "catalog/pg_type.h"
@@ -2446,6 +2447,13 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
24462447
*/
24472448
heap_insert(sd, stup);
24482449

2450+
{
2451+
Relation irelations[Num_pg_statistic_indices];
2452+
CatalogOpenIndices(Num_pg_statistic_indices, Name_pg_statistic_indices, irelations);
2453+
CatalogIndexInsert(irelations, Num_pg_statistic_indices, sd, stup);
2454+
CatalogCloseIndices(Num_pg_statistic_indices, irelations);
2455+
}
2456+
24492457
/* release allocated space */
24502458
pfree(DatumGetPointer(values[Anum_pg_statistic_stacommonval-1]));
24512459
pfree(DatumGetPointer(values[Anum_pg_statistic_staloval-1]));

src/backend/utils/adt/selfuncs.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.42 1999/11/22 17:56:30 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.43 1999/11/25 00:15:57 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -588,27 +588,20 @@ getattstatistics(Oid relid, AttrNumber attnum, Oid typid, int32 typmod,
588588
Datum *hival)
589589
{
590590
Relation rel;
591-
HeapScanDesc scan;
592-
static ScanKeyData key[2] = {
593-
{0, Anum_pg_statistic_starelid, F_OIDEQ, {0, 0, F_OIDEQ}},
594-
{0, Anum_pg_statistic_staattnum, F_INT2EQ, {0, 0, F_INT2EQ}}
595-
};
596591
bool isnull;
597592
HeapTuple tuple;
598593
HeapTuple typeTuple;
599594
FmgrInfo inputproc;
600595

601596
rel = heap_openr(StatisticRelationName, AccessShareLock);
602597

603-
key[0].sk_argument = ObjectIdGetDatum(relid);
604-
key[1].sk_argument = Int16GetDatum((int16) attnum);
605-
606-
scan = heap_beginscan(rel, 0, SnapshotNow, 2, key);
607-
tuple = heap_getnext(scan, 0);
598+
tuple = SearchSysCacheTuple(STATRELID,
599+
ObjectIdGetDatum(relid),
600+
Int16GetDatum((int16) attnum),
601+
0, 0); /* staop is currently 0 */
608602
if (!HeapTupleIsValid(tuple))
609603
{
610604
/* no such stats entry */
611-
heap_endscan(scan);
612605
heap_close(rel, AccessShareLock);
613606
return false;
614607
}
@@ -693,7 +686,6 @@ getattstatistics(Oid relid, AttrNumber attnum, Oid typid, int32 typmod,
693686
}
694687
}
695688

696-
heap_endscan(scan);
697689
heap_close(rel, AccessShareLock);
698690
return true;
699691
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy