I have just read up on clustering a table based on indexes. That is a fantastic feature. I see some tables where that will be very useful. Thanks so much for pointing this out!
Lance From: Keith Fiske <keith.fiske@xxxxxxxxxxxxxxx> On Tue, Oct 9, 2018 at 10:43 AM Campbell, Lance <lance@xxxxxxxxxxxx> wrote:
Note that a normal VACUUM will not re-arrange the data on disk to group it together. Only a VACUUM FULL will do something like that and even then it doesn't really group similar data close together. You're probably thinking of CLUSTER.
And the clustering is not automatically retained and has to be re-run periodically. But both VACUUM FULL and CLUSTER require a full lock on the table involved that blocks all access until they are done running. I wrote more about managing bloat in my blog and what vacuuming actually does if you're interested - https://www.keithf4.com/checking-for-postgresql-bloat/ Before going down the partitioning road, I would first recommend getting some bloat monitoring in place, to see if it's even a concern. If you're removing the data fairly often and not in huge chunks at a time, your deletion/ingest rate
may be balanced out. If you are seeing bloat becoming a concern, I'd recommend the smallest interval at monthly. You may even want to try yearly since your retention period is longer. The fewer partitions there are, the better. Keith |