Re: When to use PARTITION BY HASH? - Mailing list pgsql-performance

From MichaelDBA
Subject Re: When to use PARTITION BY HASH?
Date
Msg-id 1de60053-ac43-87f3-288a-55b3f31d67f7@sqlexec.com
Whole thread Raw
In response to Re: When to use PARTITION BY HASH?  (Imre Samu <pella.samu@gmail.com>)
Responses Re: When to use PARTITION BY HASH?  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-performance
The article referenced below assumes a worst case scenario for bulk-loading with hash partitioned tables.  It assumes that the values being inserted are in strict ascending or descending order with no gaps (like a sequence number incrementing by 1), thereby ensuring every partition is hit in order before repeating the process.  If the values being inserted are not strictly sequential with no gaps, then the performance is much better.  Obviously, what part of the tables and indexes are in memory has a lot to do with it as well.

Regards,
Michael Vitale

Imre Samu wrote on 6/5/2020 7:48 AM:
> "Bulk loads ...",

As I see - There is an interesting bulkload benchmark:    

"How Bulkload performance is affected by table partitioning in PostgreSQL" by Beena Emerson (Enterprisedb, December 4, 2019 )
SUMMARY: This article covers how benchmark tests can be used to demonstrate the effect of table partitioning on performance. Tests using range- and hash-partitioned tables are compared and the reasons for their different results are explained:
                 1. Range partitions
                 2. Hash partitions
                 3. Combination graphs
                 4. Explaining the behavior
                 5. Conclusion

"For the hash-partitioned table, the first value is inserted in the first partition, the second number in the second partition and so on till all the partitions are reached before it loops back to the first partition again until all the data is exhausted. Thus it exhibits the worst-case scenario where the partition is repeatedly switched for every value inserted. As a result, the number of times the partition is switched in a range-partitioned table is equal to the number of partitions, while in a hash-partitioned table, the number of times the partition has switched is equal to the amount of data being inserted. This causes the massive difference in timing for the two partition types."
Regards,
 Imre

pgsql-performance by date:

Previous
From: Cedric Leong
Date:
Subject: Re: Date vs Timestamp without timezone Partition Key
Next
From: David Rowley
Date:
Subject: Re: When to use PARTITION BY HASH?