postgresqlvacuum
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
postgresqlvacuum [2021/09/23 14:14] – z0hpvk | postgresqlvacuum [2025/03/08 22:24] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== Vacuuming ===== | ===== Vacuuming ===== | ||
+ | ==== Parameters ==== | ||
+ | < | ||
+ | autovacuum_analyze_scale_factor | ||
+ | autovacuum_analyze_threshold | ||
+ | autovacuum_vacuum_scale_factor | ||
+ | autovacuum_vacuum_threshold | ||
+ | </ | ||
+ | |||
+ | ==== Dead Rows ==== | ||
The following SQL code displays the thresholds for when Autovacuum will clean up dead rows.\\ | The following SQL code displays the thresholds for when Autovacuum will clean up dead rows.\\ | ||
Dead rows (or tuples) occur in postgres when records are updated or deleted.\\ | Dead rows (or tuples) occur in postgres when records are updated or deleted.\\ | ||
Line 16: | Line 25: | ||
order by 5 desc limit 10; | order by 5 desc limit 10; | ||
</ | </ | ||
- | < | + | |
- | autovacuum_analyze_scale_factor | + | ==== Vacuum Progress ==== |
- | autovacuum_analyze_threshold | + | Will not display the progress of VACUUM FULL commands. |
- | autovacuum_vacuum_scale_factor | + | < |
- | autovacuum_vacuum_threshold | + | SELECT p.pid, now() - a.xact_start AS duration, |
+ | coalesce(wait_event_type | ||
+ | | ||
+ | | ||
+ | WHEN a.query ~*'^vacuum' THEN ' | ||
+ | ELSE ' | ||
+ | END AS mode, | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | FROM pg_stat_progress_vacuum p | ||
+ | JOIN pg_stat_activity a using (pid) | ||
+ | ORDER BY now() - a.xact_start DESC; | ||
</ | </ | ||
+ | |||
+ | ==== Table Bloat ==== | ||
+ | Table bloat can be fixed by performing a " | ||
+ | This will create a new unfragmented table and rebuild all associated indexes.\\ | ||
+ | However this will cause a full lock on the table, even SELECT queries will have to wait for the process to complete.\\ | ||
+ | Instead you can use the extension [[https:// | ||
+ | |||
+ | The basis of the below SQL query was taken from: [[https:// | ||
+ | |||
<code SQL> | <code SQL> | ||
SELECT current_database(), | SELECT current_database(), |
postgresqlvacuum.1632406483.txt.gz · Last modified: 2025/03/08 22:23 (external edit)