A catalog cache that never caches isn't much of a cache :-(. Mea culpa.
Thanks to Brian Hirt for pointing out the performance lossage.
This commit is contained in:
parent
48437f5c3a
commit
80dab5bd69
28
src/backend/utils/cache/catcache.c
vendored
28
src/backend/utils/cache/catcache.c
vendored
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.72 2000/11/16 22:30:33 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.73 2000/11/24 04:16:12 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -258,8 +258,8 @@ CatalogCacheInitializeCache(CatCache *cache)
|
|||||||
&cache->cc_skey[i].sk_func);
|
&cache->cc_skey[i].sk_func);
|
||||||
cache->cc_skey[i].sk_nargs = cache->cc_skey[i].sk_func.fn_nargs;
|
cache->cc_skey[i].sk_nargs = cache->cc_skey[i].sk_func.fn_nargs;
|
||||||
|
|
||||||
/* Initialize sk_attno suitably for index scans */
|
/* Initialize sk_attno suitably for HeapKeyTest() and heap scans */
|
||||||
cache->cc_skey[i].sk_attno = i+1;
|
cache->cc_skey[i].sk_attno = cache->cc_key[i];
|
||||||
|
|
||||||
CACHE4_elog(DEBUG, "CatalogCacheInit %s %d %p",
|
CACHE4_elog(DEBUG, "CatalogCacheInit %s %d %p",
|
||||||
cache->cc_relname,
|
cache->cc_relname,
|
||||||
@ -664,8 +664,8 @@ InitCatCache(int id,
|
|||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* initialize the cache's relation information for the relation
|
* initialize the cache's relation information for the relation
|
||||||
* corresponding to this cache and initialize some of the the new
|
* corresponding to this cache, and initialize some of the new
|
||||||
* cache's other internal fields.
|
* cache's other internal fields. But don't open the relation yet.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
cp->cc_relname = relname;
|
cp->cc_relname = relname;
|
||||||
@ -885,10 +885,20 @@ SearchCatCache(CatCache *cache,
|
|||||||
RetrieveIndexResult indexRes;
|
RetrieveIndexResult indexRes;
|
||||||
HeapTupleData tuple;
|
HeapTupleData tuple;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
int i;
|
||||||
|
|
||||||
CACHE2_elog(DEBUG, "SearchCatCache(%s): performing index scan",
|
CACHE2_elog(DEBUG, "SearchCatCache(%s): performing index scan",
|
||||||
cache->cc_relname);
|
cache->cc_relname);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For an index scan, sk_attno has to be set to the index attribute
|
||||||
|
* number(s), not the heap attribute numbers. We assume that the
|
||||||
|
* index corresponds exactly to the cache keys (or its first N
|
||||||
|
* keys do, anyway).
|
||||||
|
*/
|
||||||
|
for (i = 0; i < cache->cc_nkeys; ++i)
|
||||||
|
cur_skey[i].sk_attno = i+1;
|
||||||
|
|
||||||
idesc = index_openr(cache->cc_indname);
|
idesc = index_openr(cache->cc_indname);
|
||||||
isd = index_beginscan(idesc, false, cache->cc_nkeys, cur_skey);
|
isd = index_beginscan(idesc, false, cache->cc_nkeys, cur_skey);
|
||||||
tuple.t_datamcxt = CurrentMemoryContext;
|
tuple.t_datamcxt = CurrentMemoryContext;
|
||||||
@ -915,18 +925,10 @@ SearchCatCache(CatCache *cache,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
HeapScanDesc sd;
|
HeapScanDesc sd;
|
||||||
int i;
|
|
||||||
|
|
||||||
CACHE2_elog(DEBUG, "SearchCatCache(%s): performing heap scan",
|
CACHE2_elog(DEBUG, "SearchCatCache(%s): performing heap scan",
|
||||||
cache->cc_relname);
|
cache->cc_relname);
|
||||||
|
|
||||||
/*
|
|
||||||
* For a heap scan, sk_attno has to be set to the heap attribute
|
|
||||||
* number(s), not the index attribute numbers.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < cache->cc_nkeys; ++i)
|
|
||||||
cur_skey[i].sk_attno = cache->cc_key[i];
|
|
||||||
|
|
||||||
sd = heap_beginscan(relation, 0, SnapshotNow,
|
sd = heap_beginscan(relation, 0, SnapshotNow,
|
||||||
cache->cc_nkeys, cur_skey);
|
cache->cc_nkeys, cur_skey);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: catcache.h,v 1.28 2000/11/16 22:30:49 tgl Exp $
|
* $Id: catcache.h,v 1.29 2000/11/24 04:16:11 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -70,7 +70,7 @@ typedef struct catcache
|
|||||||
short cc_nkeys; /* number of keys (1..4) */
|
short cc_nkeys; /* number of keys (1..4) */
|
||||||
short cc_key[4]; /* AttrNumber of each key */
|
short cc_key[4]; /* AttrNumber of each key */
|
||||||
PGFunction cc_hashfunc[4]; /* hash function to use for each key */
|
PGFunction cc_hashfunc[4]; /* hash function to use for each key */
|
||||||
ScanKeyData cc_skey[4]; /* precomputed key info for indexscans */
|
ScanKeyData cc_skey[4]; /* precomputed key info for heap scans */
|
||||||
Dllist cc_lrulist; /* overall LRU list, most recent first */
|
Dllist cc_lrulist; /* overall LRU list, most recent first */
|
||||||
Dllist cc_cache[NCCBUCK]; /* hash buckets */
|
Dllist cc_cache[NCCBUCK]; /* hash buckets */
|
||||||
} CatCache;
|
} CatCache;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user