-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed unnecessary left join and distinct #36813
Conversation
left joined table b is not used in query at all, it just generates multiple same rows, which are solved by distinct. Removing both gives the same result and removes 'using temporary table' from query explain, which could cause high performance issues on some servers. Plus add quoting on table name.
There is a longer history for this select clause - #4114 |
Vow, I didn't search so far in history. Ok, as far as I understand, #4114 replaced 'group by' by distinct, but neither of it is IMO needed, as it is used just to remove duplicate records, loaded just because there is left join, which is not needed, as there is no usage of table b neither in select list fields, nor where clause nor order by clause. |
I have tested this item ✅ successfully on 16d58d5 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36813. |
1 similar comment
I have tested this item ✅ successfully on 16d58d5 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36813. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36813. |
Merging here thanks |
left joined table b is not used in query at all, it just generates multiple same rows, which are solved by distinct. Removing both gives the same result and removes 'using temporary table' from query explain, which could cause high performance issues on some servers. Plus add quoting on table name.
Summary of Changes
left joined table b is not used in query at all, it just generates multiple same rows, which are solved by distinct. Removing both gives the same result and removes 'using temporary table' and 'Range checked for each record' from query explain, which could cause high performance issues on some servers.
Plus add quoting on table name.
Testing Instructions
Enable Debug mode, open list of articles, see generated Explain for query
Actual result BEFORE applying this Pull Request
Tags in filetr field for Tags are displayed, sorted by it ordering
Explain of query shows
Expected result AFTER applying this Pull Request
Tags in filetr field for Tags are displayed, sorted by it ordering
Query is simplified to
Explain shows
Documentation Changes Required
No
Additional info
This issue remains in 4.0 and 4.1, If accepted I could prepare PR there also.
In my case this becomes issue after moving from MySQL 5 to MySQL 8 on some server. the original query took aprox. 8s, new one is aprox 5ms.