Re: Preventing free space from being reused

2021-02-12 Thread Noah Bergbauer
>I wonder how hard it would be to hack up a table access method that is just a copy of heap where HEAP_INSERT_SKIP_FSM is always set... Update: I think this actually works. It's awful because I just copied the entire builtin heap code into an extension and then renamed a few functions so they don'

Re: Preventing free space from being reused

2021-02-12 Thread Noah Bergbauer
I'm experimenting with that right now. Setting storage to MAIN appears to be counterproductive, whereas EXTERNAL with toast_tuple_target = 128 is definitely an improvement. In theory, this configuration might eliminate the problem, but due to the toast_tuple_target bug ( https://www.postgresql.org/

Re: Preventing free space from being reused

2021-02-12 Thread Michael Lewis
If you have no updates or deletes, then I would wonder about setting fillfactor LOWER such that new rows are less likely to find a gap that is acceptable. Depending how/when you use the json, lowering toast_tuple_target may be appropriate to store (nearly?) all out of line and making the data store

Re: Preventing free space from being reused

2021-02-12 Thread Noah Bergbauer
This is on version 12.5. The usage pattern is inserts only, no updates or deletes at all. Hence, fillfactor is set to 100. It just seems extremely unfortunate in this particular case that Postgres goes to all the trouble of tetris-ing new tuples into existing pages, only to cripple performance in

Re: Preventing free space from being reused

2021-02-12 Thread Michael Lewis
What version are you using? What is your usage pattern for insert/update/deletes? If sometimes the JSON data gets too big and the data is moved from in-line storage to TOASTED, then that would be opening up gaps. Or if you are doing deletes. Perhaps adjusting your fillfactor and/or TOAST_TUPLE_TARG