diff options
Diffstat (limited to 'src/backend/utils/cache/catcache.c')
-rw-r--r-- | src/backend/utils/cache/catcache.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 80444d0a143..cc76acdd747 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.41 1999/05/25 16:12:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.42 1999/05/31 23:48:04 tgl Exp $ * * Notes: * XXX This needs to use exception.h to handle recovery when @@ -876,16 +876,18 @@ SearchSysCache(struct catcache * cache, /* ---------------- * if we found a tuple in the cache, move it to the top of the - * lru list, and return it. + * lru list, and return it. We also move it to the front of the + * list for its hashbucket, in order to speed subsequent searches. + * (The most frequently accessed elements in any hashbucket will + * tend to be near the front of the hashbucket's list.) * ---------------- */ if (elt) { - Dlelem *old_lru_elt; + Dlelem *old_lru_elt = ((CatCTup *) DLE_VAL(elt))->ct_node; - old_lru_elt = ((CatCTup *) DLE_VAL(elt))->ct_node; - DLRemove(old_lru_elt); - DLAddHead(cache->cc_lrulist, old_lru_elt); + DLMoveToFront(old_lru_elt); + DLMoveToFront(elt); #ifdef CACHEDEBUG relation = heap_open(cache->relationId); |