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

Commit402bd49

Browse files
committed
Improve the way in which CatalogCacheComputeHashValue combines multiple key
values: don't throw away perfectly good hash bits, and increase the shiftdistances so as to provide more separation in the common case where some ofthe key values are small integers (and so their hashes are too, becausehashfunc.c doesn't try all that hard). This reduces the runtime ofSearchCatCache by a factor of 4 in an example provided by Greg Stark,in which the planner spends a whole lot of time searching the two-keySTATRELATT cache. It seems unlikely to hurt in other cases, but maybewe could do even better?
1 parent11da4c6 commit402bd49

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.136 2007/01/05 22:19:42 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.137 2007/04/21 04:49:20 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -158,6 +158,7 @@ static uint32
158158
CatalogCacheComputeHashValue(CatCache*cache,intnkeys,ScanKeycur_skey)
159159
{
160160
uint32hashValue=0;
161+
uint32oneHash;
161162

162163
CACHE4_elog(DEBUG2,"CatalogCacheComputeHashValue %s %d %p",
163164
cache->cc_relname,
@@ -167,24 +168,31 @@ CatalogCacheComputeHashValue(CatCache *cache, int nkeys, ScanKey cur_skey)
167168
switch (nkeys)
168169
{
169170
case4:
170-
hashValue ^=
171+
oneHash=
171172
DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[3],
172-
cur_skey[3].sk_argument)) <<9;
173+
cur_skey[3].sk_argument));
174+
hashValue ^=oneHash <<24;
175+
hashValue ^=oneHash >>8;
173176
/* FALLTHROUGH */
174177
case3:
175-
hashValue ^=
178+
oneHash=
176179
DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[2],
177-
cur_skey[2].sk_argument)) <<6;
180+
cur_skey[2].sk_argument));
181+
hashValue ^=oneHash <<16;
182+
hashValue ^=oneHash >>16;
178183
/* FALLTHROUGH */
179184
case2:
180-
hashValue ^=
185+
oneHash=
181186
DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[1],
182-
cur_skey[1].sk_argument)) <<3;
187+
cur_skey[1].sk_argument));
188+
hashValue ^=oneHash <<8;
189+
hashValue ^=oneHash >>24;
183190
/* FALLTHROUGH */
184191
case1:
185-
hashValue ^=
192+
oneHash=
186193
DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[0],
187194
cur_skey[0].sk_argument));
195+
hashValue ^=oneHash;
188196
break;
189197
default:
190198
elog(FATAL,"wrong number of hash keys: %d",nkeys);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp