Optimize(Search): use LEFT JOIN filter on SELECT statement for Consumable #17078
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.
From the list of
Consumable
, using the following search filters together causes data to load slowlyNumber of new consumables
Number of used consumables
This simple
SQL
statementTakes almost 1 min 11,978 sec to return the results (42 rows)
Here is an
EXPLAIN
of thisSQL
queryNumber of new consumables
->42 rows in set (0,037 sec)
Number of used consumables
->42 rows in set (0,058 sec)
The double left join on the glpi_consumables table seems to be the cause
But as this is not my area of expertise, I can't say why
glpi_consumables
-> 39652,glpi_consumableitems
-> 63 )To try and optimise this SQL query, I decided to deport the filter included in the
LEFT JOIN
directly into theSELECT
statementThis optimized SQL query takes almost 0,041 sec to return the results (42 rows) 👍
Here is an
EXPLAIN
of this optimizedSQL
querynote that this PR -> #16999
did not solve this problem (which must be different)