J3 Issue ?
avatar richard67
richard67
22 Jun 2019

Steps to reproduce the issue

Install current staging and check database view in backend.

Expected result

No database errors.

Actual result

1 error: Table 'xyz_template_styles' should not have index 'idx_home'. (From file 3.9.8-2019-06-15.sql.)

System information (as much as possible)

Current staging or nightly build 3.9.9-dev which includes merged PR #24595 .

MySQL database.

Additional comments

Problem is that database schema checker can't handle changes of indexes like done with PR #24595 in files 3.9.8-2019-06-15.sql in a proper way. Maybe it helps to put it into separate files.

avatar richard67 richard67 - open - 22 Jun 2019
avatar joomla-cms-bot joomla-cms-bot - change - 22 Jun 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 22 Jun 2019
avatar richard67
richard67 - comment - 22 Jun 2019

Ping @alikon 👅

avatar franz-wohlkoenig franz-wohlkoenig - change - 22 Jun 2019
Labels Added: J3 Issue
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 22 Jun 2019
avatar alikon
alikon - comment - 22 Jun 2019

i confirm your findings.... not sure if splitting sql in more files can help... but ... if you have some free time, please explore it .... i'm currently busy in moving home, so i cannot be responsive like i should do

avatar richard67
richard67 - comment - 22 Jun 2019

Will work on it today or tomorrow. Just wanted to leave an issue so others know it is already reported.

avatar richard67
richard67 - comment - 23 Jun 2019

@alikon The problem is that the database schema checker can't really handle remove and later add back index with same name, and it would be not easy to change that.

Question is: Do we really need that index for the home column?

Or isn't it true that we in sql selects always ask only for value of home column for a particular client_id?

In this case we would have a combined index on columns client_id, home, so we could add that new index instead of adding back the old index one home column, and that new index would have a different name anyway so all would be ok.

Update: Or we just remove that index if not used or not performance relevant anyway. I guess there are no sites having hundreds of template styles.

How can we easily find out if that index is useful or not?

avatar richard67
richard67 - comment - 23 Jun 2019

@alikon I've checked where clauses of select statements to the #__template_styles table and have seen that an index on the single column home does not really make sense.

But I saw that a combined index on columns client_id and home makes sense, see e.g. here:

In addition, an index on the single column client_id makes sense, but it does not exist yet, see e.g. here:

https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_templates/models/styles.php#L117-L118

Also I've checked that the existing index on the single column template still makes sense, so we can keep it, see e.g. here:

https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_templates/models/template.php#L1228-L1229

Finally I've found a typo you made in the schema update for postgresql in your PR #24595 (ALTER TABLE "#__template_style" instead of ALTER TABLE "#__template_styles").

I will make PR to fix all that, and then this issue should be fixed, too.

avatar richard67 richard67 - change - 23 Jun 2019
Status New Closed
Closed_Date 0000-00-00 00:00:00 2019-06-23 11:42:06
Closed_By richard67
avatar richard67
richard67 - comment - 23 Jun 2019

Closing as having PR #25299 .

avatar richard67 richard67 - close - 23 Jun 2019
avatar alikon
alikon - comment - 24 Jun 2019

The problem is that the database schema checker can't really handle remove and later add back index with same name, and it would be not easy to change that.

my fault i I thought it was possible.... surely i remeber wrong .....

and yes indexes are not so much usefull for this table in general .... cause i think that this table never reach a cardinality were the QueryPlanner should find more "economic" to use an index instead of a table scan of few rows....

btw for a good db schema design we can use an index for the used where clause like you did

avatar richard67
richard67 - comment - 24 Jun 2019

@alikon Could you the test or - if not much time - review the PR for this issue, #25299 ? Or both, test and review, if enough time?

avatar alikon
alikon - comment - 24 Jun 2019

done and thank you to dig in this

Add a Comment

Login with GitHub to post a comment