[WIP] improve indexes to query decisions #1010
Draft
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.
Master plan, pre-implem
Everytying in this PR is about the
decisions
table and its indexes.Some preliminary comments based on my exploration
vacuum full
does not update the visibility map - only regular vacuum does. So you need to runvacuum
after avacuum full
- and it takes quite some time to run. (No particular impact on our prod where we can't dofull
, but interesting still)Actual changes
Revamp indexes
Current indexes on the table
In total, 9 indexes + PK, and 3 of them are filtered on decisions with a case, 1 filtered on decisions with a scheduled_exec_id
New set of indexes
For specific workflows:
Very specific indexes, makes sense to have them as we « hope » they are automatically chosen if one of the object_id, pivot_value filters are passed (which are expected to be some of the main filters):
Strong filters, limited index size (in most setups):
Otherwise, default to this:
=> 8 indexes +PK, out of which 3 are filtered on decisions with cases, 1 filtered on batch decisions, and one on decisions that have a non null pivot value (So 4 or 5 « large » ones in total).
Schema changes
varchar(10)
=>text
Config changes
setnot relevant, can't update TOAST_TUPLE_THRESHOLD paramtoast_tuple_target
on the table, value TBD but probably in the 256-ish range.autovacuum_vacuum_insert_scale_factor
to something like 0.02, andautovacuum_analyze_scale_factor
to 0.01 (1/10 of the default values)