Very inefficient queries in some parts of the site
Problem/Motivation
With the current volume of modern Drupal branches and its number of objects created, some old queries (from the D7 days) suddenly become very inefficient and demanding for the database server.
This is due to making queries like this ->condition('d.object_name', '%\_' . $hook_name, 'LIKE'), which means that even if we add an index to the column, this won't be used.
Steps to reproduce
The blocks:
- Similar classes in this and other branches
- Reference/implementations/invocations
Use that query, so that's most pages in the site.
Proposed resolution
Create a new column when saving objects, and then when storing functions, we can store the full name in "object_name" (currently doing that) and the potential "hook_name" in the new column.
That'll change the above query to be ->condition('d.hook_name', $hook_name) and we will be able to create an index too.
Remaining tasks
- MR
- Enable the line commented out like // @todo Remove temporary to review query performance.
- Create index in the new column