DB is bloated and cleanup doesn't help

Hello,

We have a bloated database (we are using postgresql) of 500Gb.
We tried cleaning up manually all old branches and PRs and analyses (and they were a lot , more than 500..) from all projects on the instance using the rest api of sonarqube, however we haven’t seen any decrease in db size. Any idea why the database size didn’t change? Any suggestion on how to decrease it?

Regards,
Cindy

Hi,

That’s expected behavior with most of the databases. When you delete data (e.g., old branches, PRs, analyses), the space isn’t immediately freed on disk, it’s just marked for reuse.

To actually reduce the database size, you need to run a VACUUM FULL, which rewrites the tables and reclaims the space. Just note it locks tables while running, so it’s best done during a maintenance window. You might also consider running REINDEX DATABASE afterward to recover index space. Please check the documentation on VACUUM for more details.