Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit80dab5b

Browse files
committed
A catalog cache that never caches isn't much of a cache :-(. Mea culpa.
Thanks to Brian Hirt for pointing out the performance lossage.
1 parent48437f5 commit80dab5b

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

‎src/backend/utils/cache/catcache.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.72 2000/11/16 22:30:33 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.73 2000/11/24 04:16:12 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -258,8 +258,8 @@ CatalogCacheInitializeCache(CatCache *cache)
258258
&cache->cc_skey[i].sk_func);
259259
cache->cc_skey[i].sk_nargs=cache->cc_skey[i].sk_func.fn_nargs;
260260

261-
/* Initialize sk_attno suitably forindex scans */
262-
cache->cc_skey[i].sk_attno=i+1;
261+
/* Initialize sk_attno suitably forHeapKeyTest() and heap scans */
262+
cache->cc_skey[i].sk_attno=cache->cc_key[i];
263263

264264
CACHE4_elog(DEBUG,"CatalogCacheInit %s %d %p",
265265
cache->cc_relname,
@@ -664,8 +664,8 @@ InitCatCache(int id,
664664

665665
/* ----------------
666666
*initialize the cache's relation information for the relation
667-
*corresponding to this cache and initialize some of the the new
668-
*cache's other internal fields.
667+
*corresponding to this cache, and initialize some of the new
668+
*cache's other internal fields. But don't open the relation yet.
669669
* ----------------
670670
*/
671671
cp->cc_relname=relname;
@@ -885,10 +885,20 @@ SearchCatCache(CatCache *cache,
885885
RetrieveIndexResultindexRes;
886886
HeapTupleDatatuple;
887887
Bufferbuffer;
888+
inti;
888889

889890
CACHE2_elog(DEBUG,"SearchCatCache(%s): performing index scan",
890891
cache->cc_relname);
891892

893+
/*
894+
* For an index scan, sk_attno has to be set to the index attribute
895+
* number(s), not the heap attribute numbers. We assume that the
896+
* index corresponds exactly to the cache keys (or its first N
897+
* keys do, anyway).
898+
*/
899+
for (i=0;i<cache->cc_nkeys;++i)
900+
cur_skey[i].sk_attno=i+1;
901+
892902
idesc=index_openr(cache->cc_indname);
893903
isd=index_beginscan(idesc, false,cache->cc_nkeys,cur_skey);
894904
tuple.t_datamcxt=CurrentMemoryContext;
@@ -915,18 +925,10 @@ SearchCatCache(CatCache *cache,
915925
else
916926
{
917927
HeapScanDescsd;
918-
inti;
919928

920929
CACHE2_elog(DEBUG,"SearchCatCache(%s): performing heap scan",
921930
cache->cc_relname);
922931

923-
/*
924-
* For a heap scan, sk_attno has to be set to the heap attribute
925-
* number(s), not the index attribute numbers.
926-
*/
927-
for (i=0;i<cache->cc_nkeys;++i)
928-
cur_skey[i].sk_attno=cache->cc_key[i];
929-
930932
sd=heap_beginscan(relation,0,SnapshotNow,
931933
cache->cc_nkeys,cur_skey);
932934

‎src/include/utils/catcache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
16-
* $Id: catcache.h,v 1.28 2000/11/16 22:30:49 tgl Exp $
16+
* $Id: catcache.h,v 1.29 2000/11/24 04:16:11 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -70,7 +70,7 @@ typedef struct catcache
7070
shortcc_nkeys;/* number of keys (1..4) */
7171
shortcc_key[4];/* AttrNumber of each key */
7272
PGFunctioncc_hashfunc[4];/* hash function to use for each key */
73-
ScanKeyDatacc_skey[4];/* precomputed key info forindexscans */
73+
ScanKeyDatacc_skey[4];/* precomputed key info forheap scans */
7474
Dllistcc_lrulist;/* overall LRU list, most recent first */
7575
Dllistcc_cache[NCCBUCK];/* hash buckets */
7676
}CatCache;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp