doc/development/database/partitioning/hash.md
Hash partitioning is a method of dividing a large table into smaller, more manageable partitions based on a hash function applied to a specified column, typically the ID column. It offers unique advantages for certain use cases, but it also comes with limitations.
Key points:
HASH(ID) with MODULUS 64 and REMAINDER 1, rows with hash(ID) % 64 == 1 would go into the corresponding partition.WHERE hashed_column = ? condition,
as this allows PostgreSQL to quickly identify the relevant partition.Upfront decisions:
Unsupported query types:
(WHERE id BETWEEN ? AND ?) and lookups by other keys (WHERE other_id = ?) are not directly supported on hash-partitioned tables.Considerations:
In summary, hash partitioning is a valuable tool for specific scenarios, particularly when ID uniqueness across partitions is crucial. However, it's essential to carefully consider its limitations and query patterns before implementation.