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

Commitf5dff44

Browse files
committed
I've attached a simple patch which should improve the performance of
hashname() and reduce the penalty incured when NAMEDATALEN is increased.I posted this to -hackers a couple days ago, and there haven't been anymajor complaints. It passes the regression tests. See -hackers for morediscussion, as well as the suggestion from Tom Lane on which this patchis based.Unless anyone sees any problems, please apply for 7.3.Cheers,Neil Conway
1 parent7464e7f commitf5dff44

File tree

3 files changed

+8
-26
lines changed

3 files changed

+8
-26
lines changed

‎src/backend/access/hash/hashfunc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.30 2001/03/22 03:59:13 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.31 2002/02/25 04:06:47 momjian Exp $
1212
*
1313
* NOTES
1414
* These functions are stored in pg_amproc.For each operator class
@@ -95,7 +95,7 @@ hashname(PG_FUNCTION_ARGS)
9595
{
9696
char*key=NameStr(*PG_GETARG_NAME(0));
9797

98-
returnhash_any((char*)key,NAMEDATALEN);
98+
returnhash_any(key,strlen(key));
9999
}
100100

101101
/*
@@ -125,7 +125,7 @@ hashvarlena(PG_FUNCTION_ARGS)
125125
*
126126
* (Comment from the original db3 hashing code: )
127127
*
128-
*"This is INCREDIBLY ugly, but fast. We break the string up into 8 byte
128+
* This is INCREDIBLY ugly, but fast. We break the string up into 8 byte
129129
* units. On the first time through the loop we get the 'leftover bytes'
130130
* (strlen % 8). On every later iteration, we perform 8 HASHC's so we handle
131131
* all 8 bytes. Essentially, this saves us 7 cmp & branch instructions. If
@@ -134,7 +134,7 @@ hashvarlena(PG_FUNCTION_ARGS)
134134
* "OZ's original sdbm hash"
135135
*/
136136
Datum
137-
hash_any(char*keydata,intkeylen)
137+
hash_any(constchar*keydata,intkeylen)
138138
{
139139
uint32n;
140140
intloop;

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

Lines changed: 2 additions & 20 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.87 2002/02/19 20:11:17 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.88 2002/02/25 04:06:50 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -97,7 +97,6 @@ static Index CatalogCacheComputeHashIndex(CatCache *cache,
9797
staticIndexCatalogCacheComputeTupleHashIndex(CatCache*cache,
9898
HeapTupletuple);
9999
staticvoidCatalogCacheInitializeCache(CatCache*cache);
100-
staticDatumcc_hashname(PG_FUNCTION_ARGS);
101100
#ifdefCATCACHE_STATS
102101
staticvoidCatCachePrintStats(void);
103102
#endif
@@ -116,7 +115,7 @@ GetCCHashFunc(Oid keytype)
116115
caseCHAROID:
117116
returnhashchar;
118117
caseNAMEOID:
119-
returncc_hashname;
118+
returnhashname;
120119
caseINT2OID:
121120
returnhashint2;
122121
caseINT2VECTOROID:
@@ -137,23 +136,6 @@ GetCCHashFunc(Oid keytype)
137136
}
138137
}
139138

140-
staticDatum
141-
cc_hashname(PG_FUNCTION_ARGS)
142-
{
143-
/*
144-
* We need our own variant of hashname because we want to accept
145-
* null-terminated C strings as search values for name fields. So, we
146-
* have to make sure the data is correctly padded before we compute
147-
* the hash value.
148-
*/
149-
NameDatamy_n;
150-
151-
namestrcpy(&my_n,NameStr(*PG_GETARG_NAME(0)));
152-
153-
returnDirectFunctionCall1(hashname,NameGetDatum(&my_n));
154-
}
155-
156-
157139
#ifdefCATCACHE_STATS
158140

159141
staticvoid

‎src/include/access/hash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: hash.h,v 1.42 2001/11/05 17:46:31 momjian Exp $
10+
* $Id: hash.h,v 1.43 2002/02/25 04:06:52 momjian Exp $
1111
*
1212
* NOTES
1313
*modeled after Margo Seltzer's hash implementation for unix.
@@ -265,7 +265,7 @@ extern Datum hashoidvector(PG_FUNCTION_ARGS);
265265
externDatumhashint2vector(PG_FUNCTION_ARGS);
266266
externDatumhashname(PG_FUNCTION_ARGS);
267267
externDatumhashvarlena(PG_FUNCTION_ARGS);
268-
externDatumhash_any(char*keydata,intkeylen);
268+
externDatumhash_any(constchar*keydata,intkeylen);
269269

270270

271271
/* private routines */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp