Skip to content

Commit

Permalink
Remove compression stat update from update script
Browse files Browse the repository at this point in the history
Updating the compression stats can potentially be a very big task
locking many tables, so we remove it from the update script. We also
remove the check from the update test.

Fixes timescale#2859
  • Loading branch information
mkindahl committed Jan 26, 2021
1 parent dc3561d commit 126f1c8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 63 deletions.
34 changes: 0 additions & 34 deletions sql/updates/2.0.0-rc3--2.0.0-rc4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -127,37 +127,3 @@ ON DELETE CASCADE;
GRANT SELECT ON _timescaledb_catalog.hypertable_id_seq TO PUBLIC;
GRANT SELECT ON _timescaledb_catalog.hypertable TO PUBLIC;
--End Modify hypertable table

-- update metadata for chunks compressed before 2.0
DO $$
DECLARE
plain_chunk RECORD;
comp_chunk TEXT;
rowcount_pre BIGINT;
rowcount_post BIGINT;
BEGIN
FOR plain_chunk IN
SELECT
*
FROM
_timescaledb_catalog.chunk comp
WHERE
compressed_chunk_id IS NOT NULL LOOP
SELECT
format('%I.%I', schema_name, table_name) INTO comp_chunk
FROM
_timescaledb_catalog.chunk
WHERE
id = plain_chunk.compressed_chunk_id;
EXECUTE format('SELECT sum(_ts_meta_count), count(*) FROM %s', comp_chunk) INTO rowcount_pre, rowcount_post;
UPDATE
_timescaledb_catalog.compression_chunk_size
SET
numrows_pre_compression = rowcount_pre,
numrows_post_compression = rowcount_post
WHERE
chunk_id = plain_chunk.id;
END LOOP;
END
$$;

29 changes: 0 additions & 29 deletions test/sql/updates/post.compression.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,3 @@ WHERE
AND chunk.compressed_chunk_id IS NULL;

SELECT * FROM compress ORDER BY time DESC, small_cardinality;

-- check count and approximate_row_count are the same after analyze
ANALYZE compress;
SELECT
count,
approximate,
CASE WHEN count != approximate THEN
'counts not matching' || random()::TEXT
ELSE
'match'
END AS MATCH
FROM (
SELECT
count(*)
FROM
compress) AS count,
approximate_row_count('compress') AS approximate;

SELECT
hypertable_schema,
hypertable_name,
approximate_row_count(format('%I.%I', hypertable_schema, hypertable_name)::REGCLASS)
FROM
timescaledb_information.hypertables
WHERE
compression_enabled = true
ORDER BY
1,
2;

0 comments on commit 126f1c8

Please sign in to comment.