Skip to content

Commit

Permalink
Enable autovacuum for existing compressed chunks
Browse files Browse the repository at this point in the history
In old TSDB versions, we disabled autovacuum for compressed chunks to
keep the statistics. However, this restriction was removed in timescale#5118, but
no migration was performed to enable autovacuum for existing chunks.
  • Loading branch information
jnidzwetzki committed Mar 8, 2024
1 parent b719787 commit 3da84cc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion sql/updates/latest-dev.sql
Expand Up @@ -161,4 +161,21 @@ DROP FUNCTION IF EXISTS _timescaledb_functions.get_chunk_colstats;
DROP FUNCTION IF EXISTS _timescaledb_internal.get_chunk_relstats;
DROP FUNCTION IF EXISTS _timescaledb_internal.get_chunk_colstats;


# In old TSDB versions, we disabled autovacuum for compressed chunks
# to keep the statistics. However, this restriction was removed in
# #5118 but no migration was performed to enable autovacuum
# for existing chunks.
DO $$
DECLARE
chunk regclass;
BEGIN
FOR chunk IN
SELECT format('%I.%I', schema_name, table_name)::regclass
FROM _timescaledb_catalog.chunk WHERE compressed_chunk_id IS NOT NULL
LOOP
EXECUTE format('ALTER TABLE %s RESET (autovacuum_enabled);', chunk::text)
;
END LOOP;
END
$$;
DO

0 comments on commit 3da84cc

Please sign in to comment.