Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does postgres calculate multi column hashes?

Tags:

postgresql

In PG I have a table which is using partition by hash (*text*, *bigint*) looking at a previous answer the functions used for hashing can be seen however I'm unsure which function is used to build combined hashes?

Is it treating the partition keys as a record and using hash_record?

Ultimately I want to know this to rebuild the hashing function in Java to optimise reads and writes to specific partitions.

like image 202
Stephen Flavin Avatar asked Dec 21 '25 21:12

Stephen Flavin


1 Answers

The hash_combine64 is used for calculating the ultimate hash value. According to the comments in the code it's based on the boost's hash_combine approach. Also, you can find the whole partition calculation algorithm in compute_partition_hash_value function.

like image 70
Ilia Maskov Avatar answered Dec 26 '25 02:12

Ilia Maskov