-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Sql optimise new index merged branch #10284
Sql optimise new index merged branch #10284
Conversation
fix conflicts 1) #__contentitem_tag_map
fix conflicts 2) #__extensions
fix conflicts 2) #__extensions
fix conflicts 1) #__contentitem_tag_map
fix conflicts 3) #__languages
fix conflicts 4) #__menu
fix conflicts 3) #__languages
fix conflicts 4) #__menu
fix conflicts 5) #__session
fix conflicts 6) #__template_styles
Do all the new indexes work with utf8mb4? I ask because it seems to be a bit older. |
@richard67 should work with utf8mb4 too, yes it is very old comes from gsoc 2014 |
@alikon Do you have a suggestion how to test the update behaviour as "database fix" can´t be used anymore and there is no update package? |
ALTER TABLE `#__session` DROP PRIMARY KEY, ADD PRIMARY KEY (session_id(32)); | ||
ALTER TABLE `#__session` DROP INDEX `time`, ADD INDEX `time` (time(10)); | ||
ALTER TABLE `#__template_styles` ADD INDEX `idx_client_id` (`client_id`); | ||
ALTER TABLE `#__contentitem_tag_map` ADD INDEX `idx_alias_item_id` (`type_alias`,`content_item_id`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
ALTER TABLE
#__contentitem_tag_map
ADD INDEXidx_alias_item_id
(type_alias
(100),content_item_id
);
in order to work with utf8mb4, because the InnoDB storage engine has a maximum index length of 767 bytesm which is max. 191 characters in utf8mb4, and for consistence with all other indexes we should use max. 100 characters.
Correct idx_alias_item_id for mysql utf8mb4 and add missing name quotes on other indexes with lengths limits for columns. The idx_alias_item_id might not have lead to an SQL error before with utf8mb4 in case if not in strict session mode, but it would for sure make problems later. The missing quotes I have added are cosmetics only and do not do any harm. I texted this script with the modification I proposed here in phpMyAdmin.
@waader What do you mean with
? |
This is what I did:
With all the changes in the installer I concluded that this procedure is not possible anymore. |
Well as I just checked in "libraries/cms/schema/changeitem/mysql.php", the database fix does not handle "DROP PRIMARY KEY" and "ADD PRIMARY KEY" statements, so these will not be detected by the databaase fix as structural change and so will be skipped. Furthermore, the "DROP INDEX" and "ADD INDEX" statements in 1 row are also not detected as a structural change, because the database fix checks only for index names, not for details. But the "ADD INDEX" for really new indexes should have worked. So as it is now, the schema updates of this PR will only be applied when using Joomla! Update component for updating, but not when using the "copy or extract the files and use the database fix" method. But regardless of all that, the correction for utf8mb4 I provided above has to be made. @wilsonge Please confirm what I found. |
we already have some sql on update to 3.6.0 that for what i understand from your comments will not work ... https://github.com/joomla/joomla-cms/tree/staging/administrator/components/com_admin/sql/updates/mysql so the Database -> Fix behaviour needs to be Fixed 😉 |
Yes, is all known issues. Just wanted to explain here so people will not test in the wrong way. But despite of this, my correction for utf8mb4 has to be applied, otherwise 1 of these new indexes will not work because max index size exceeded. |
yes richard i understand that |
Correct idx_alias_item_id for mysql utf8mb4
I have tested this item ✅ successfully on 95ac0fc This is what I did:
Done a code review and all seems fine. PS: While checking i notice some intensive queries (example: SHOW FULL COLUMNS FROM This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10284. |
I want to test that PR. I have 2 requests/questions:
ALTER TABLE `#__contentitem_tag_map` ADD UNIQUE `idx_cid_type_alias_tag_id` (`type_alias`, `content_item_id`, `tag_id`); |
Can you look at resolving the conflicts so that this can be tested please or is it so out of date that it should be closed? |
It has been 10 months since the request for this pr to be updated without reply. I am going to close it as an abandoned issue. It can always be reopened if updated |
Pull Request for fix conflict of #4115 .
Summary of Changes
conflict fixed and added mssql and postgresql compatibility
Testing Instructions:
This PR consists all the PRs merged in to this one regarding the index additions. Two approaches can be followed in order to test this PR. One is in an already installed site and one is for fresh distributions.
For already installed sites
For already installed sites first apply the PR and then add follow the bellow commands in order to add the indexes manually to the database
ALTER TABLE #__languages ADD INDEX 'idx_published_ordering' ('published','ordering');
(#11)Related Query Before changes
Related Query Before changes
ALTER TABLE #__session DROP PRIMARY KEY, ADD PRIMARY KEY(session_id(32))
( #8 )ALTER TABLE #__session DROP INDEX time, ADD INDEX time(time(10))
Index Description
This Index added in order to speed up the session update query allowing the sub string index usages
ALTER TABLE #__template_styles ADD INDEX idx_client_id('client_id')
( #13 )Index Description
Without applying this index the below query cannot use any index to retrieve the rows from the database. After applying this index it clearly shows in the explanation section that the query uses the index to retrieve the rows
Related Query
ALTER TABLE #__contentitem_tag_map ADD INDEX idx_alias_item_id ('type_alias','content_item_id')
( #14 )Index Description
Without applying this index the below query cannot use any index to retrieve the rows from the database. After applying this index it clearly shows in the explanation section that the query uses the index to retrieve the rows. Also one another change did relevant to this index changes. Which is removing the
t.*
from the relevant query and adding the table fields instead. This change can be found (#14) and please refer to that PR also.Related Query Before changes
Related Query After changes
ALTER TABLE #__extensions ADD INDEX 'idx_type_ordering' ('type','ordering')
( #16 )Index Description
Without applying this index the below query uses
filesort
to retrieve the rows from the database, which is an expensive retrieval operation. After applying this index it clearly shows in the explanation section that the query uses the index to retrieve the rows except thefilesort
.Related Query
ALTER TABLE #__menu ADD INDEX 'idx_client_id_published_lft' ('client_id','published','lft')
( #17 )Index Description
Without applying this index the below query uses
filesort
to retrieve the rows from the database, which is an expensive retrieval operation. After applying this index it clearly shows in the explanation section that the query uses the index to retrieve the rows except thefilesort
.Related Query
(query Executes when clicking on the add new category in the admin console)
ALTER TABLE #__viewlevels ADD INDEX
idx_ordering_title(
ordering,
title)
( #21 )Index Description
Without applying this index the below query uses
filesort
to retrieve the rows from the database, which is an expensive retrieval operation. After applying this index it clearly shows in the explanation section that the query uses the index to retrieve the rows except thefilesort
. Also changed theJROOT/libraries/cms/html/access.php
file's query which is shown below by removing theGROUP BY
clause since thePRIMARY KEY
includes in the selected fields. And this reduce the execution timeRelated Query Before Change
Related Query After Change
Testing Instructions