Skip to content

Draft: Add audit even index on `[entity_type, entity_id]`

Michael Becker requested to merge feat/337757-pt1 into master

While working on MR 107166 for issue 337757 I ran the existing SQL query and the proposed new one through joe bot using explain

Both the original and new had the same suggestion to add an index:

Specialized index needed – The index(es) currently used does not serve
quite well for the needs of this query (notice Rows Removed by Filter:
..., meaning that the index fetched many non-target rows). Consider
adding more specialized index(es).

I wanted to add the index first before making any changes to the query to better isolate the performance impact of any new/modified queries

To add the index I followed the database guides below:

This commit adds the post-deployment migration to add the index

A followup commit/mr will be needed to add the schema changes after the index is created in production

Edited by Michael Becker

Merge request reports