跳到主要内容
跳到主要内容

XXHASH_64

xxhash_64

description

Syntax

BIGINT XXHASH_64(VARCHAR input, ...)

返回输入字符串的64位xxhash值。

注:在计算hash值时,更推荐使用xxhash_64,而不是murmur_hash3_64

example

mysql> select xxhash_64(NULL);
+-----------------+
| xxhash_64(NULL) |
+-----------------+
| NULL |
+-----------------+

mysql> select xxhash_64("hello");
+----------------------+
| xxhash_64('hello') |
+----------------------+
| -7685981735718036227 |
+----------------------+

mysql> select xxhash_64("hello", "world");
+-----------------------------+
| xxhash_64('hello', 'world') |
+-----------------------------+
| 7001965798170371843 |
+-----------------------------+

benchmark

通过TPCH Benchmark测试发现,xxhash_64相比murmur_hash3_64来说性能大幅提升,因此在需要计算hash值的场景下,更推荐使用xxhash_64

mysql> select count(murmur_hash3_64(l_comment)) from lineitem;
+-----------------------------------+
| count(murmur_hash3_64(l_comment)) |
+-----------------------------------+
| 600037902 |
+-----------------------------------+
1 row in set (17.18 sec)

mysql> select count(xxhash_64(l_comment)) from lineitem;
+-----------------------------+
| count(xxhash_64(l_comment)) |
+-----------------------------+
| 600037902 |
+-----------------------------+
1 row in set (8.41 sec)

keywords

XXHASH_64,HASH