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

[framework] VACUUM FULL ANALYZE is now run once a week #3160

Open
wants to merge 3 commits into
base: 15.0
Choose a base branch
from

Conversation

vitek-rostislav
Copy link
Contributor

@vitek-rostislav vitek-rostislav commented May 10, 2024

Q A
Description, reason for the PR It is a good practice to garbage-collect the Postgres database once in a while in production to avoid performance issues. We added a CRON module that performs VACUUM FULL ANALYZE on the database once a week so we don't have to think about it and run it manually anymore.
New feature Yes
BC breaks No
Fixes issues ...
Have you read and signed our License Agreement for contributions? Yes

🌐 Live Preview:

@vitek-rostislav vitek-rostislav added Enhancement New feature or request for change from user point of view Performance Performance labels May 10, 2024
$this->logger->info('Cron lock was released.');
}

protected function waitUntilOtherCronModulesOff(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those functions are just duplicated in our base:

waitUntilOtherCronModulesOff() -> CronWatchCommand
lockAllCronModules() -> CronLockCommand
maintenanceOn() and maintenanceOff() -> MaintenanceModeCommand

try {
$this->waitUntilOtherCronModulesOff();
$this->maintenanceOn();
$this->makeVacuum();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the idea of making VACUUM FULL from the application. Additionally, you should run VACUUM FULL as an edge case and not regularly.

Postgres has AUTOVACUUM that should handle bloat in databases. If you have miswritten your application then you have to use VACUUM FULL. Running it periodically covers problems in your application.

Another view can be that ANALYSE rebuilds all statistics instead of updating them. So this means that this command can negatively impact the performance of some SQL commands.

I don't say we should entirely avoid using VACUUM FULL, but we should do that manually as an edge case.

There is an outdated but still relevant article about it: https://wiki.postgresql.org/wiki/VACUUM_FULL

@vitek-rostislav vitek-rostislav added the Status: on hold Issue cannot be resolved right now or is waiting for something label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request for change from user point of view Performance Performance Status: on hold Issue cannot be resolved right now or is waiting for something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants