Problem/Motivation
When building a view based on content revisions which uses the moderation control state filter, it takes a long time for the query to finish executing. With large data sets (+1 000 000 rows) it takes more than a minute to execute the query. This is a huge performance issue which makes it impossible to use a moderation state filter in conjunction with showing content revisions.
Steps to reproduce
You'll need a large data set to see the performance issue clearly
- Fresh install
- Enable content moderation
- Create a content revisions view
- Add a moderation control state filter
Proposed resolution
Create an index for moderation state in the content moderation state field revision table. Doing this would decrease the query execution time to a fraction. Testing by creating the index directly in the db made the execution time go from > 1 min to < 1 second.
Remaining tasks
1. Create patch which adds an index to moderation state field revision table
2. Add tests