Sample Header Ad - 728x90

Postgresql 12 Custom Hash Function

0 votes
2 answers
1082 views
I have a large table that I would like to partition. The field I want to partition against is a string that contains a coded value, but appears as an integer stored as a string. The "number" is made up of 4 digits. The first two are what I want to partition against. For instance, the field value of "1298", would need to partition using the value 12. I thought this would be a great use for a hash partition with a custom hash function. **For some reference:** Queries are frequently made against this column in the form of ... WHERE TheField = '0123' or ... WHERE TheField IN ('0123', '0145', '0232') It would be impractical to manually each value to go into each partition, so I thought using a custom hash function would be a practical solution. **Actual Question:** How do I make this custom hash function and use it to define the partitions?
Asked by techdude1996 (1 rep)
Sep 14, 2021, 04:41 PM
Last activity: Feb 13, 2023, 11:03 PM