Hashing used in Citus #5007
Answered
by
marcocitus
Rohit25negi
asked this question in
Q&A
-
What is the Hashin technique used in Citus. Normal modulo hashing or consistent hashing? |
Beta Was this translation helpful? Give feedback.
Answered by
marcocitus
Jun 1, 2021
Replies: 1 comment 4 replies
-
Consistent hashing. If you look at pg_dist_shard you see the range of hash values for each shard: select * from pg_dist_shard where logicalrelid = 'test'::regclass;
┌──────────────┬─────────┬──────────────┬───────────────┬───────────────┐
│ logicalrelid │ shardid │ shardstorage │ shardminvalue │ shardmaxvalue │
├──────────────┼─────────┼──────────────┼───────────────┼───────────────┤
│ test │ 102008 │ t │ -2147483648 │ -2013265921 │
│ test │ 102009 │ t │ -2013265920 │ -1879048193 │
│ test │ 102010 │ t │ -1879048192 │ -1744830465 │
│ test │ 102011 │ t │ -1744830464 │ -1610612737 │
│ test │ 102012 │ t │ -1610612736 │ -1476395009 │
│ test │ 102013 │ t │ -1476395008 │ -1342177281 │
│ test │ 102014 │ t │ -1342177280 │ -1207959553 │
│ test │ 102015 │ t │ -1207959552 │ -1073741825 │
│ test │ 102016 │ t │ -1073741824 │ -939524097 │
│ test │ 102017 │ t │ -939524096 │ -805306369 │
│ test │ 102018 │ t │ -805306368 │ -671088641 │
│ test │ 102019 │ t │ -671088640 │ -536870913 │
│ test │ 102020 │ t │ -536870912 │ -402653185 │
│ test │ 102021 │ t │ -402653184 │ -268435457 │
│ test │ 102022 │ t │ -268435456 │ -134217729 │
│ test │ 102023 │ t │ -134217728 │ -1 │
│ test │ 102024 │ t │ 0 │ 134217727 │
│ test │ 102025 │ t │ 134217728 │ 268435455 │
│ test │ 102026 │ t │ 268435456 │ 402653183 │
│ test │ 102027 │ t │ 402653184 │ 536870911 │
│ test │ 102028 │ t │ 536870912 │ 671088639 │
│ test │ 102029 │ t │ 671088640 │ 805306367 │
│ test │ 102030 │ t │ 805306368 │ 939524095 │
│ test │ 102031 │ t │ 939524096 │ 1073741823 │
│ test │ 102032 │ t │ 1073741824 │ 1207959551 │
│ test │ 102033 │ t │ 1207959552 │ 1342177279 │
│ test │ 102034 │ t │ 1342177280 │ 1476395007 │
│ test │ 102035 │ t │ 1476395008 │ 1610612735 │
│ test │ 102036 │ t │ 1610612736 │ 1744830463 │
│ test │ 102037 │ t │ 1744830464 │ 1879048191 │
│ test │ 102038 │ t │ 1879048192 │ 2013265919 │
│ test │ 102039 │ t │ 2013265920 │ 2147483647 │
└──────────────┴─────────┴──────────────┴───────────────┴───────────────┘
(32 rows) The hash function is the native hash function defined for each type in Postgres. You can call it from SQL using the |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
Rohit25negi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consistent hashing.
If you look at pg_dist_shard you see the range of hash values for each shard: