Open blattersturm opened 4 years ago
Hello This is a known limitation, postgresql does not allow to change toast tables directly.
I can suggest one method for your case:
SELECT id FROM tablename WHERE pg_column_size(long_column_name) > 800;
(for example into temp table)VACUUM VERBOSE pg_toast.pg_toast_(your toast id)
UPDATE tablename SET long_column_name = long_column_name || '' WHERE id in (...)
(assuming text type or something like that), so postgresql will think this is another toast value and write new valueVACUUM VERBOSE pg_toast.pg_toast_(your toast id)
againSo postgresql will write new TOAST values in free space near to begin of table. The tail of the table should become empty and empty pages may be cut off by vacuum. Same idea that uses pgcompacttable, but we not known which values are stored in the tail of table and which rows we need update.
We have a table with a lot of wasted space in
pg_toast
storage (~80 GB out of 200 GB total data) and would like to be able to repack it, however specifying pg_toast schema and the pg_toast_oid table leads to the script not finding the table, and toast does not get compacted when we try to compact the original table.Trying to force it to compact the toast table leads to some errors like the following:
Sadly, we can't do a full offline vacuum as we do not have the ability to add any local storage or free up enough disk space for storing 120 GB of data temporarily - it'd be neat if this script were capable of compacting toast. 😕