Skip to content

Adds a db/repair CLI command#16812

Merged
brandonkelly merged 6 commits into4.15from
feature/db-repair
Mar 5, 2025
Merged

Adds a db/repair CLI command#16812
brandonkelly merged 6 commits into4.15from
feature/db-repair

Conversation

@angrybrad
Copy link
Copy Markdown
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

Comment thread src/console/controllers/DbController.php Outdated
Comment thread src/console/controllers/DbController.php
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