A new storage engine for PostgreSQL to provide better control over bloat
amitkapila16.blogspot.com
amitkapila16.blogspot.com
We would occasionally resort to taking the customer offline for scheduled maintenance to do a pg_dump/pg_restore to get their DB back in shape.
I'm very curious to hear when this might become available for production use cases.
EDIT: Article states this has been proposed for Postgres 12
Edit: My statement about updates is not correct, see comments below
Vacuum Full works but it requires a full table lock so we could only use it on select tables for smaller customers. For large tables Vacuum Full can take many minutes and once you need to take downtime pg_dump/pg_restore becomes an option.
Where did you read this?..
Only if there are long running transactions older than the updates themselves. When no old transactions are left, vacuum reclaims old tuples.
If you're talking about vacuum being unable to reclaim pages that still have some live tuples, that problem affects deletes and updates equally.
I have heard plenty of people use pg_repack so maybe it got better or we didn't test it enough.
(edit: Missed an "and")
[1] https://www.postgresql.org/docs/10/static/sql-createtable.ht...
For indexes, using concurrent reindex to create new indexes and dropping the old can make a difference.
Yeah, it would be nice if more of this were automated and it's good that there's work being done. There are some options available in existing that can ameliorate bloat.
"I would like to mention that the above results don't mean that zheap will be better in all cases than heap. For example, rollbacks will be costlier in zheap. Just to be clear, this storage format is proposed as another format alongside current heap, so that users can decide which storage they want to use for their use case."
Certainly there are complicated trade-offs here. Some things to consider: (1) unless the pages get flushed to disk due to memory pressure or a checkpoint, the UNDO data won't hit the disk so that '2x write' isn't a disk write, (2) in-place updates don't require every index to be updated (only indexes whose key changed), skipping the famous "write amplification" problem (more generally than HOT can), (3) the 2x reads for transactions that need modified rows applies only to transactions running with old snapshots; in the traditional system every transaction pays for reading past the bloat that can't be cleaned up (in other words, an old snapshot is a tax on every transaction in the traditional design, but UNDO is only a tax on the transaction that's using an old snapshot in this proposed system).
Am I understanding that correctly?
[1] Our DBs are currently all SQL Server, but due to licensing costs, we're going to do all new stuff in pg, and over time, migrate the legacy stuff.
[2] I see there are other across-the-board benefits from e.g., smaller tuple headers; I'm talking about the main thrust.
I think there are other benefits too in terms of just raw performance because it avoids a lot of work like HOT pruning. Yes, it instead needs to discard undo, but that is much cheaper.
In general, I think it is an overstatement to say that this is a wasted effort.
I’m not going to pretend to understand all of this, but is there not a trade off here? Is MVCC not fast and concurrent because it does create new rows instead of trying to mutate the old/current ones, would it be slower writes?
In other words, are we sacrificing speed for less storage consumption?
In zheap, we need to write an old row in undo, but in many cases, it won't be written to disk as undo worker will discard the undo very quickly unless there are open snapshots. In this, we don't need to perform Hot-pruning. So, there is an additional cost of memory copy, but that is more than compensated by savings.
You can read 'macdice' reply in this regards.