Skip to content

Adds a db/repair CLI command #16812

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

Merged
merged 6 commits into from
Mar 5, 2025
Merged

Adds a db/repair CLI command #16812

merged 6 commits into from
Mar 5, 2025

Conversation

angrybrad
Copy link
Member

@angrybrad angrybrad commented Mar 2, 2025

On MySQL, this runs OPTIMIZE TABLE on each table in the database.

https://dev.mysql.com/doc/refman/8.4/en/optimize-table.html

On PostgreSQL, this runs ANALYZE VERBOSE on each table in the database.

https://www.postgresql.org/docs/current/sql-analyze.html

These run on the individual tables on separate statements to minimize the amount of table locking that happens.

You can alternatively run these using the mysqlcheck -o, but we’re avoiding that because we can’t be guaranteed it’s available on the installation or that it’s the correct version. PostgreSQL doesn’t have an equivalent CLI tool for this.

Tested on MySQL and PostgreSQL in DDEV and Craft Cloud.

Can be merged into Craft 5.

Relevant docs to update (@AugustMiller)
https://craftcms.com/docs/4.x/installation.html (and for 5)
https://craftcms.com/knowledge-base/troubleshooting-performance-issues#the-database

@brandonkelly brandonkelly merged commit 0ab414f into 4.15 Mar 5, 2025
4 checks passed
@brandonkelly brandonkelly deleted the feature/db-repair branch March 5, 2025 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants