Allow using pg_repack
on state_groups_state
by adding a primary key or UNIQUE constraint #10308
Description
Description:
It would be nice if pg_repack
could be used on the state_groups_state
table, which often has quite a lot of bloat after purging rooms / history. pg_repack
is similar to VACUUM FULL
but it can be run online without taking an exclusive lock on the tables.
pg_repack
has the following requirement on the table it is run against:
Target table must have a PRIMARY KEY, or at least a UNIQUE total index on a NOT NULL column.
Currently the state_groups_state
table does not have a primary key or UNIQUE NOT NULL keys. event_id
seems like a great candidate for this, though I'm not sure if setting a TEXT value as primary key would have any performance implications.
EDIT: it seems that none of the columns in the table is actually unique. To allow the table to be used by pg_repack, we might need to add an auto-incrementing separate primary key.