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. +-----------------+
  7. mysql> select xxhash_64("hello");
  8. +----------------------+
  9. | xxhash_64('hello') |
  10. +----------------------+
  11. | -7685981735718036227 |
  12. +----------------------+
  13. mysql> select xxhash_64("hello", "world");
  14. +-----------------------------+
  15. | xxhash_64('hello', 'world') |
  16. +-----------------------------+
  17. | 7001965798170371843 |
  18. +-----------------------------+

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

keywords

XXHASH_64,HASH