Skip to content

xxHash functions in the Hashfuncs DuckDB extension

Function category

xxHash

5 functions

Yann Collet's [xxHash](https://cyan4973.github.io/xxHash/) family — among the fastest non-cryptographic hashes available, with excellent distribution. [`xxh3_64`](#xxh3_64) is a sensible modern default; the 128-bit variants ([`xxh3_128`](#xxh3_128), [`xxh3_128_hex`](#xxh3_128_hex)) give you more headroom against accidental collisions and a portable hex digest format used by [Python xxhash](https://pypi.org/project/xxhash/) and [xxhash-rust](https://docs.rs/xxhash-rust/latest/xxhash_rust/).

xxh3_128

Scalar function xxHash
Signature
2 overloaded forms · click to inspect
Arguments (Positional)
Argument value Type ANY Mode Positional Description
Description
1 128-bit hash
SELECT xxh3_128('hello world');

Output

xxh3_128('hello world')
225447084758876380551077147957698971904
2 Seeded
SELECT xxh3_128('hello world', 42);

Output

xxh3_128('hello world', 42)
173805935617512661584987041130904516770

xxh3_128_hex

Scalar function xxHash
Signature
4 overloaded forms · click to inspect
Arguments (Positional)
Argument col0 Type BLOB Mode Positional Description
Description
1 32-char hex digest
SELECT xxh3_128_hex('hello');

Output

xxh3_128_hex('hello')
c779cfaa5e523818b5e9c1ad071b3e7f
2 Seeded variant
SELECT xxh3_128_hex('hello', 42);

Output

xxh3_128_hex('hello', 42)
8c2f5b7e4cd59e166ce89a0bdba81f08

xxh3_64

Scalar function xxHash
Signature
2 overloaded forms · click to inspect
Arguments (Positional)
Argument value Type ANY Mode Positional Description
Description
1 Default unseeded
SELECT xxh3_64('hello world');

Output

xxh3_64('hello world')
15296390279056496779
2 Seeded for partitioning
SELECT xxh3_64('hello world', 999);

Output

xxh3_64('hello world', 999)
3002856137354040482

xxh32

Scalar function xxHash
Signature
2 overloaded forms · click to inspect
Arguments (Positional)
Argument value Type ANY Mode Positional Description
Description
1 Hash a string
SELECT xxh32('hello world');

Output

xxh32('hello world')
3468387874
2 Seeded variant — independent hash space
SELECT xxh32('hello world', 42);

Output

xxh32('hello world', 42)
4225033588

xxh64

Scalar function xxHash
Signature
2 overloaded forms · click to inspect
Arguments (Positional)
Argument value Type ANY Mode Positional Description
Description
1 64-bit hash of a string
SELECT xxh64('hello world');

Output

xxh64('hello world')
5020219685658847592
2 Seeded
SELECT xxh64('hello world', 42);

Output

xxh64('hello world', 42)
7620854247404556961