hash4() function
The hash4() function returns a 32-bit checksum hash of data.
This function provides 232 (approximately 4,000,000,000) distinct return values and is intended for data retrieval (lookups).
Syntax
int4 = hash4(varchar data [, int algorithm]);
int4 = hash4(nvarchar data [, int algorithm]);
The data value
specifies the varchar or nvarchar value to
hash.
algorithm value
can be one of the following values:- 0
- Adler. This is the default.
- 1
- CRC32.
Adler is the fastest checksum hash that is provided. However, it has poor coverage when the messages are less than a few hundred bytes. (Poor coverage means that two different integers hash to the same value, which is referred to as a “collision.”) In this case, use the CRC32 algorithm or switch to the hash8() function.
Returns
The function returns hashed data.
Example
select hash4('Netezza',0);
HASH4
-----------
186778338
(1 row)