如何解决预测 Postgres 中哈希分区的分区号
在 Postgres 11 上有这个简单的表和分区定义
Place
ap=# \d+ hp
Partitioned table "public.hp"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+--------+-----------+----------+---------+---------+--------------+-------------
foo | bigint | | | | plain | |
Partition key: HASH (foo)
Partitions: hp_0 FOR VALUES WITH (modulus 10,remainder 0),hp_1 FOR VALUES WITH (modulus 10,remainder 1),hp_2 FOR VALUES WITH (modulus 10,remainder 2),hp_3 FOR VALUES WITH (modulus 10,remainder 3),hp_4 FOR VALUES WITH (modulus 10,remainder 4),hp_5 FOR VALUES WITH (modulus 10,remainder 5),hp_6 FOR VALUES WITH (modulus 10,remainder 6),hp_7 FOR VALUES WITH (modulus 10,remainder 7),hp_8 FOR VALUES WITH (modulus 10,remainder 8),hp_9 FOR VALUES WITH (modulus 10,remainder 9)
无法解释 14 是如何落在分区 hp_0 中的。从我收集到的 bigint 哈希函数是 hashint8
insert into hp values(14);
SELECT tableoid::regclass,* FROM hp;
tableoid | foo
----------+-----
hp_0 | 14
(1 row)
-1018458207 mod 10 将是 -7
-1018458207 转换为无符号整数和 mod 10 ==> 3276509089 mod 10 = 9
所以无法看到它是如何落在 hp_0 中的,即余数为 0。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。