xxHash functions in the Hashfuncs DuckDB extension
Function category
xxHash
5 functionsYann 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/).
Signature
2 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Argument
seed
|
Type
UBIGINT
|
Mode Positional | Description |
Description
128-bit xxHash3 (XXH3_128) returned as a UHUGEINT. The wider hash space dramatically reduces accidental-collision probability for very large keyspaces (billions of distinct keys).
Use when 64 bits feels tight — content fingerprints, dedup keys at scale, or any place a 64-bit birthday-bound starts to matter. For a portable hex digest instead of a number, use xxh3_128_hex.
SELECT xxh3_128('hello world');
Output
| xxh3_128('hello world') |
|---|
| 225447084758876380551077147957698971904 |
SELECT xxh3_128('hello world', 42);
Output
| xxh3_128('hello world', 42) |
|---|
| 173805935617512661584987041130904516770 |
Signature
4 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
BLOB
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
VARCHAR
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
BLOB
|
Mode Positional | Description |
Argument
col1
|
Type
UBIGINT
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
seed
|
Type
UBIGINT
|
Mode Positional | Description |
Description
128-bit xxHash3 returned as a 32-character lowercase hex string in canonical xxHash byte order (low64 || high64), as defined by the xxHash specification.
Matches the digest produced by XXH128_canonicalFromHash in C, xxhash.xxh3_128().hexdigest() in Python, and xxhash-rust when formatted as hex. Use it when the hash needs to be a string — Redis keys, filenames, or a fingerprint shared with non-SQL code.
SELECT xxh3_128_hex('hello');
Output
| xxh3_128_hex('hello') |
|---|
| c779cfaa5e523818b5e9c1ad071b3e7f |
SELECT xxh3_128_hex('hello', 42);
Output
| xxh3_128_hex('hello', 42) |
|---|
| 8c2f5b7e4cd59e166ce89a0bdba81f08 |
Signature
2 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Argument
seed
|
Type
UBIGINT
|
Mode Positional | Description |
Description
64-bit xxHash3 (XXH3_64) — the modern xxHash variant tuned for vectorized CPUs (SSE2/AVX2). Faster than xxh64 on virtually all modern hardware, especially for short inputs, with comparable distribution quality.
This is the recommended general-purpose 64-bit non-cryptographic hash for partitioning, sharding, deduplication, and as input to probabilistic filters in bitfilters.
SELECT xxh3_64('hello world');
Output
| xxh3_64('hello world') |
|---|
| 15296390279056496779 |
SELECT xxh3_64('hello world', 999);
Output
| xxh3_64('hello world', 999) |
|---|
| 3002856137354040482 |
Related functions
- xxh3_128() — 128-bit xxHash3 (XXH3_128) returned as a `UHUGEINT`
- xxh3_128_hex() — 128-bit xxHash3 returned as a 32-character lowercase hex string in canonical xxHash byte order (`low64 || high64`), as defined by the xxHash specification
- xxh64() — 64-bit xxHash (XXH64)
- rapidhash() — RapidHash — a 64-bit non-cryptographic hash designed for exceptional speed while keeping competitive distribution quality
Signature
2 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Argument
seed
|
Type
UINTEGER
|
Mode Positional | Description |
Description
32-bit xxHash (XXH32) — the classic 32-bit member of the xxHash family. Fast and well-distributed; use when 32 bits is enough — for in-memory hashtables, lightweight checksums, or short-lived bucket assignment.
Accepts an optional UINTEGER seed. Prefer xxh3_64 when you don't have a specific reason to use the 32-bit format — XXH3 is faster on modern hardware and offers more headroom against collisions.
SELECT xxh32('hello world');
Output
| xxh32('hello world') |
|---|
| 3468387874 |
SELECT xxh32('hello world', 42);
Output
| xxh32('hello world', 42) |
|---|
| 4225033588 |
Related functions
- xxh64() — 64-bit xxHash (XXH64)
- xxh3_64() — 64-bit xxHash3 (XXH3_64) — the modern xxHash variant tuned for vectorized CPUs (SSE2/AVX2)
- xxh3_128() — 128-bit xxHash3 (XXH3_128) returned as a `UHUGEINT`
- xxh3_128_hex() — 128-bit xxHash3 returned as a 32-character lowercase hex string in canonical xxHash byte order (`low64 || high64`), as defined by the xxHash specification
Signature
2 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Argument
seed
|
Type
UBIGINT
|
Mode Positional | Description |
Description
64-bit xxHash (XXH64). The original 64-bit xxHash — broadly supported across language bindings and on-the-wire identical to xxHash 0.6.x callers.
Pick xxh64 when you must match an existing XXH64-based system; otherwise xxh3_64 is faster on modern CPUs.
SELECT xxh64('hello world');
Output
| xxh64('hello world') |
|---|
| 5020219685658847592 |
SELECT xxh64('hello world', 42);
Output
| xxh64('hello world', 42) |
|---|
| 7620854247404556961 |