xxhash_64

description

Syntax

BIGINT XXHASH_64(VARCHAR input, ...)

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

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

example

1. mysql> select xxhash_64(NULL);
2. +-----------------+
3. | xxhash_64(NULL) |
4. +-----------------+
5. |            NULL |
6. +-----------------+

8. mysql> select xxhash_64("hello");
9. +----------------------+
10. | xxhash_64('hello')   |
11. +----------------------+
12. | -7685981735718036227 |
13. +----------------------+

15. mysql> select xxhash_64("hello", "world");
16. +-----------------------------+
17. | xxhash_64('hello', 'world') |
18. +-----------------------------+
19. |         7001965798170371843 |
20. +-----------------------------+

benchmark

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

1. mysql> select count(murmur_hash3_64(l_comment)) from lineitem;
2. +-----------------------------------+
3. | count(murmur_hash3_64(l_comment)) |
4. +-----------------------------------+
5. |                         600037902 |
6. +-----------------------------------+
7. 1 row in set (17.18 sec)

9. mysql> select count(xxhash_64(l_comment)) from lineitem;
10. +-----------------------------+
11. | count(xxhash_64(l_comment)) |
12. +-----------------------------+
13. |                   600037902 |
14. +-----------------------------+
15. 1 row in set (8.41 sec)

keywords

XXHASH_64,HASH