Make index on orders table much more useful on Postgres #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've noticed that the index
bmsql_oorder_idx1
isn't very useful on Postgres. In fact, it generally isn't used at all with more than about 1000 warehouses, at least with my optimizedpostgresql.conf
, which is used with Postgres git HEAD -- this can be confirmed by queryingpg_stat_user_indexes
. (I have communicated with @wieck about this privately.)It is possible to completely remove the current
bmsql_oorder_idx1
index without apparent downside on Postgres, which ensures that the orders table gets HOT updates -- clearly a big benefit. However, it would be even more beneficial (particularly for query latency) if we were to revise the index's definition instead, while accepting non-HOT updates as a cost worth paying to enable index only scans. The TPC-C workload seems to highly reward this approach. It's not like VACUUM does all that badly with keeping visibility map bits set. (Though it could do a lot better, which is something that I'm working to address in Postgres itself.)This approach is particularly beneficial for the ORDER_STATUS transaction, which can be confirmed fairly easily -- just run BenchmarkSQL with a couple of hundred warehouses for a few hours to see the difference (cannot confirm that it'll work as well on all Postgres versions, but I think it should work the same on Postgres 11+).
It will be even more informative if you can run with this revised index definition with 1000+ warehouse, for 6+ hours. That will allow you to see a systemic improvement. The broader improvement has a lot to do with the fact that VACUUM doesn't need to delete any index pages in this revised
bmsql_oorder_idx1
index -- whereas it has to delete a large number of them today. That's pretty pathological, just on its own.I realize that this change doesn't belong under
sql.common
-- it's really a vendor-specific optimization that applies only to PostgreSQL 11+. We can deal with that after basic validation. My guess is that the currentbmsql_oorder_idx1
index is actually a vendor-specific optimization for Oracle -- the current definition is not justified by the spec, and already seems roughly in the same spirit as this revised definition.Thanks