postgresqlvacuum
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| postgresqlvacuum [2022/02/13 22:59] – z0hpvk | postgresqlvacuum [2025/03/08 22:24] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 27: | Line 27: | ||
| ==== Vacuum Progress ==== | ==== Vacuum Progress ==== | ||
| + | Will not display the progress of VACUUM FULL commands. | ||
| <code SQL> | <code SQL> | ||
| - | SELECT | + | SELECT p.pid, now() - a.xact_start AS duration, |
| - | p.pid, | + | |
| - | now() - a.xact_start AS duration, | + | |
| - | coalesce(wait_event_type ||' | + | |
| - | CASE | + | |
| - | WHEN a.query ~*' | + | |
| - | WHEN a.query ~*' | + | |
| - | ELSE ' | + | |
| - | END AS mode, | + | |
| - | p.datname AS database, | + | |
| - | p.relid:: | + | |
| - | p.phase, | + | |
| - | pg_size_pretty(p.heap_blks_total * current_setting(' | + | |
| - | pg_size_pretty(pg_total_relation_size(relid)) AS total_size, | + | |
| - | pg_size_pretty(p.heap_blks_scanned * current_setting(' | + | |
| - | pg_size_pretty(p.heap_blks_vacuumed * current_setting(' | + | FROM pg_stat_progress_vacuum p |
| - | round(100.0 * p.heap_blks_scanned / p.heap_blks_total, | + | JOIN pg_stat_activity a using (pid) |
| - | round(100.0 * p.heap_blks_vacuumed / p.heap_blks_total, | + | |
| - | p.index_vacuum_count, | + | |
| - | round(100.0 * p.num_dead_tuples / p.max_dead_tuples, | + | |
| - | FROM pg_stat_progress_vacuum p | + | |
| - | JOIN pg_stat_activity a using (pid) | + | |
| ORDER BY now() - a.xact_start DESC; | ORDER BY now() - a.xact_start DESC; | ||
| </ | </ | ||
| Line 57: | Line 53: | ||
| This will create a new unfragmented table and rebuild all associated indexes.\\ | 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.\\ | 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:// | The basis of the below SQL query was taken from: [[https:// | ||
postgresqlvacuum.1644793188.txt.gz · Last modified: (external edit)
