Skip to content
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

Ensure to perform complex column updates only when supported #22232

Merged
merged 3 commits into from
May 27, 2024
Merged

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented May 17, 2024

Description:

Some database engines, like TiDb, are performing sanity checks for table updates. Those might include checking if all columns used already exist. In such a case a query that adds a new column and e.g. directly uses it for an index will fail.

This PR changes how dimension updates are performed, so queries are executed separately instead of combined, if the database doesn't support it.

The same is applied for the AddColumns database migration class. It allows adding multiple columns, while every column will be placed after the one added before. This might also fail, so each column needs to be added separately

Review

@sgiehl sgiehl added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. labels May 17, 2024
@sgiehl sgiehl added this to the 5.1.0 milestone May 17, 2024
@michalkleiner
Copy link
Contributor

The addition on its own makes sense, but do we need two ways of writing such update queries? Can we live with the simple approach only where each column, each index needs to be added separately? Would it be such a huge performance penalty for database engines that do support the complex queries?

@sgiehl
Copy link
Member Author

sgiehl commented May 21, 2024

@michalkleiner We can't ensure that it won't cause performance problems when executing the queries one by one for all database engines. Adding or changing columns and indices, can always cause a full index rebuilt. When executed as one query, the database might only rebuilt the index once, as it performs all other changes before. In separate queries it might cause an index to be rebuilt multiple times, which can take ages depending on the table and data included.

@michalkleiner
Copy link
Contributor

Good point, the index rebuild didn't cross my mind.

@michalkleiner
Copy link
Contributor

Do we have some tests for the Updater to test the mechanism?

@sgiehl
Copy link
Member Author

sgiehl commented May 21, 2024

The are some tests covering that partially. The Installation only sets up the base schema and afterwards all dimension changes / updates will be performed. That should be covered by the installation UI tests.
In addition there is a UI test, that performs an update from an old Matomo 1.6 database. That should cover the change for the migration.
But both for sure currently only cover the case when complex updates are supported (here). The other case will be covered at some point by the TiDb PR.

@sgiehl sgiehl merged commit b9a695e into 5.x-dev May 27, 2024
24 of 25 checks passed
@sgiehl sgiehl deleted the dev-18012 branch May 27, 2024 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants