summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane1999-05-31 23:48:04 +0000
committerTom Lane1999-05-31 23:48:04 +0000
commit185b4272844970a9e1b46eb3d1d16d4e5ecca939 (patch)
tree9bfdfa7e5323f5bcf0ecc8a357fb737dd4821bf0 /src/backend/utils
parent2a44383a2d38ac4655e419cb8c2c654efe960285 (diff)
Fix some latent bugs in dllist.c (carelessness about setting
all fields that should be set). Add a MoveToFront primitive to speed up one of the hotspots in SearchSysCache.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/cache/catcache.c14
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);