xxhash_64

description

Syntax

BIGINT XXHASH_64(VARCHAR input, ...)

Return the 64 bits xxhash of input string.

Note: When calculating hash values, it is more recommended to use xxhash_64 instead of 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

Through TPCH Benchmark testing, it was found that xxhash_64 has significantly improved performance compared to murmur_hash3_64. Therefore, in scenarios where hash values need to be calculated, it is more recommended to use 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