Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make VACUUM tests more resilient #3085

Merged
merged 2 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
141 changes: 135 additions & 6 deletions test/expected/vacuum.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- LICENSE-APACHE for a copy of the license.
CREATE TABLE vacuum_test(time timestamp, temp float);
-- create hypertable with three chunks
SELECT create_hypertable('vacuum_test', 'time', chunk_time_interval => 2628000000000);
SELECT create_hypertable('vacuum_test', 'time', chunk_time_interval => 2628000000000, create_default_indexes => false);
NOTICE: adding not-null constraint to column "time"
create_hypertable
--------------------------
Expand Down Expand Up @@ -33,22 +33,18 @@ ORDER BY tablename, attname, array_to_string(histogram_bounds, ',');

VACUUM (VERBOSE, ANALYZE) vacuum_test;
INFO: vacuuming "_timescaledb_internal._hyper_1_1_chunk"
INFO: index "_hyper_1_1_chunk_vacuum_test_time_idx" now contains 2 row versions in 2 pages
INFO: "_hyper_1_1_chunk": found 0 removable, 2 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "_timescaledb_internal._hyper_1_1_chunk"
INFO: "_hyper_1_1_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: vacuuming "_timescaledb_internal._hyper_1_2_chunk"
INFO: index "_hyper_1_2_chunk_vacuum_test_time_idx" now contains 2 row versions in 2 pages
INFO: "_hyper_1_2_chunk": found 0 removable, 2 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "_timescaledb_internal._hyper_1_2_chunk"
INFO: "_hyper_1_2_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: vacuuming "_timescaledb_internal._hyper_1_3_chunk"
INFO: index "_hyper_1_3_chunk_vacuum_test_time_idx" now contains 2 row versions in 2 pages
INFO: "_hyper_1_3_chunk": found 0 removable, 2 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "_timescaledb_internal._hyper_1_3_chunk"
INFO: "_hyper_1_3_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: vacuuming "public.vacuum_test"
INFO: index "vacuum_test_time_idx" now contains 0 row versions in 1 pages
INFO: "vacuum_test": found 0 removable, 0 nonremovable row versions in 0 out of 0 pages
INFO: analyzing "public.vacuum_test"
INFO: "vacuum_test": scanned 0 of 0 pages, containing 0 live rows and 0 dead rows; 0 rows in sample, 0 estimated total rows
Expand Down Expand Up @@ -83,7 +79,7 @@ ORDER BY tablename, attname, array_to_string(histogram_bounds, ',');
DROP TABLE vacuum_test;
--test plain analyze (no_vacuum)
CREATE TABLE analyze_test(time timestamp, temp float);
SELECT create_hypertable('analyze_test', 'time', chunk_time_interval => 2628000000000);
SELECT create_hypertable('analyze_test', 'time', chunk_time_interval => 2628000000000, create_default_indexes => false);
NOTICE: adding not-null constraint to column "time"
create_hypertable
---------------------------
Expand Down Expand Up @@ -148,6 +144,7 @@ ORDER BY tablename, attname, array_to_string(histogram_bounds, ',');
analyze_test | time | {"Fri Jan 20 16:00:01 2017","Sat Jan 21 16:00:01 2017","Thu Apr 20 16:00:01 2017","Fri Apr 21 16:00:01 2017","Tue Jun 20 16:00:01 2017","Wed Jun 21 16:00:01 2017"} | -1
(2 rows)

DROP TABLE analyze_test;
-- Run vacuum on a normal (non-hypertable) table
CREATE TABLE vacuum_norm(time timestamp, temp float);
INSERT INTO vacuum_norm VALUES ('2017-01-20T09:00:01', 17.5),
Expand All @@ -161,3 +158,135 @@ INFO: vacuuming "public.vacuum_norm"
INFO: "vacuum_norm": found 0 removable, 6 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "public.vacuum_norm"
INFO: "vacuum_norm": scanned 1 of 1 pages, containing 6 live rows and 0 dead rows; 6 rows in sample, 6 estimated total rows
DROP TABLE vacuum_norm;
--Similar to normal vacuum tests, but PG11 introduced ability to vacuum multiple tables at once, we make sure that works for hypertables as well.
CREATE TABLE vacuum_test(time timestamp, temp float);
-- create hypertable with three chunks
SELECT create_hypertable('vacuum_test', 'time', chunk_time_interval => 2628000000000, create_default_indexes => false);
NOTICE: adding not-null constraint to column "time"
create_hypertable
--------------------------
(3,public,vacuum_test,t)
(1 row)

INSERT INTO vacuum_test VALUES ('2017-01-20T16:00:01', 17.5),
('2017-01-21T16:00:01', 19.1),
('2017-04-20T16:00:01', 89.5),
('2017-04-21T16:00:01', 17.1),
('2017-06-20T16:00:01', 18.5),
('2017-06-21T16:00:01', 11.0);
CREATE TABLE analyze_test(time timestamp, temp float);
SELECT create_hypertable('analyze_test', 'time', chunk_time_interval => 2628000000000, create_default_indexes => false);
NOTICE: adding not-null constraint to column "time"
create_hypertable
---------------------------
(4,public,analyze_test,t)
(1 row)

INSERT INTO analyze_test VALUES ('2017-01-20T16:00:01', 17.5),
('2017-01-21T16:00:01', 19.1),
('2017-04-20T16:00:01', 89.5),
('2017-04-21T16:00:01', 17.1),
('2017-06-20T16:00:01', 18.5),
('2017-06-21T16:00:01', 11.0);
CREATE TABLE vacuum_norm(time timestamp, temp float);
INSERT INTO vacuum_norm VALUES ('2017-01-20T09:00:01', 17.5),
('2017-01-21T09:00:01', 19.1),
('2017-04-20T09:00:01', 89.5),
('2017-04-21T09:00:01', 17.1),
('2017-06-20T09:00:01', 18.5),
('2017-06-21T09:00:01', 11.0);
-- no stats
SELECT tablename, attname, histogram_bounds, n_distinct FROM pg_stats
WHERE schemaname = '_timescaledb_internal' AND tablename LIKE '_hyper_%_chunk'
ORDER BY tablename, attname, array_to_string(histogram_bounds, ',');
tablename | attname | histogram_bounds | n_distinct
-----------+---------+------------------+------------
(0 rows)

SELECT tablename, attname, histogram_bounds, n_distinct FROM pg_stats
WHERE schemaname = 'public'
ORDER BY tablename, attname, array_to_string(histogram_bounds, ',');
tablename | attname | histogram_bounds | n_distinct
-----------+---------+------------------+------------
(0 rows)

VACUUM (VERBOSE, ANALYZE) vacuum_norm, vacuum_test, analyze_test;
INFO: vacuuming "_timescaledb_internal._hyper_3_7_chunk"
INFO: "_hyper_3_7_chunk": found 0 removable, 2 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "_timescaledb_internal._hyper_3_7_chunk"
INFO: "_hyper_3_7_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: vacuuming "_timescaledb_internal._hyper_3_8_chunk"
INFO: "_hyper_3_8_chunk": found 0 removable, 2 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "_timescaledb_internal._hyper_3_8_chunk"
INFO: "_hyper_3_8_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: vacuuming "_timescaledb_internal._hyper_3_9_chunk"
INFO: "_hyper_3_9_chunk": found 0 removable, 2 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "_timescaledb_internal._hyper_3_9_chunk"
INFO: "_hyper_3_9_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: vacuuming "_timescaledb_internal._hyper_4_10_chunk"
INFO: "_hyper_4_10_chunk": found 0 removable, 2 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "_timescaledb_internal._hyper_4_10_chunk"
INFO: "_hyper_4_10_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: vacuuming "_timescaledb_internal._hyper_4_11_chunk"
INFO: "_hyper_4_11_chunk": found 0 removable, 2 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "_timescaledb_internal._hyper_4_11_chunk"
INFO: "_hyper_4_11_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: vacuuming "_timescaledb_internal._hyper_4_12_chunk"
INFO: "_hyper_4_12_chunk": found 0 removable, 2 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "_timescaledb_internal._hyper_4_12_chunk"
INFO: "_hyper_4_12_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: vacuuming "public.vacuum_norm"
INFO: "vacuum_norm": found 0 removable, 6 nonremovable row versions in 1 out of 1 pages
INFO: analyzing "public.vacuum_norm"
INFO: "vacuum_norm": scanned 1 of 1 pages, containing 6 live rows and 0 dead rows; 6 rows in sample, 6 estimated total rows
INFO: vacuuming "public.vacuum_test"
INFO: "vacuum_test": found 0 removable, 0 nonremovable row versions in 0 out of 0 pages
INFO: analyzing "public.vacuum_test"
INFO: "vacuum_test": scanned 0 of 0 pages, containing 0 live rows and 0 dead rows; 0 rows in sample, 0 estimated total rows
INFO: analyzing "public.vacuum_test" inheritance tree
INFO: "_hyper_3_7_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: "_hyper_3_8_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: "_hyper_3_9_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: vacuuming "public.analyze_test"
INFO: "analyze_test": found 0 removable, 0 nonremovable row versions in 0 out of 0 pages
INFO: analyzing "public.analyze_test"
INFO: "analyze_test": scanned 0 of 0 pages, containing 0 live rows and 0 dead rows; 0 rows in sample, 0 estimated total rows
INFO: analyzing "public.analyze_test" inheritance tree
INFO: "_hyper_4_10_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: "_hyper_4_11_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: "_hyper_4_12_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
-- stats should exist for all 6 chunks
SELECT tablename, attname, histogram_bounds, n_distinct FROM pg_stats
WHERE schemaname = '_timescaledb_internal' AND tablename LIKE '_hyper_%_chunk'
ORDER BY tablename, attname, array_to_string(histogram_bounds, ',');
tablename | attname | histogram_bounds | n_distinct
-------------------+---------+---------------------------------------------------------+------------
_hyper_3_7_chunk | temp | {17.5,19.1} | -1
_hyper_3_7_chunk | time | {"Fri Jan 20 16:00:01 2017","Sat Jan 21 16:00:01 2017"} | -1
_hyper_3_8_chunk | temp | {17.1,89.5} | -1
_hyper_3_8_chunk | time | {"Thu Apr 20 16:00:01 2017","Fri Apr 21 16:00:01 2017"} | -1
_hyper_3_9_chunk | temp | {11,18.5} | -1
_hyper_3_9_chunk | time | {"Tue Jun 20 16:00:01 2017","Wed Jun 21 16:00:01 2017"} | -1
_hyper_4_10_chunk | temp | {17.5,19.1} | -1
_hyper_4_10_chunk | time | {"Fri Jan 20 16:00:01 2017","Sat Jan 21 16:00:01 2017"} | -1
_hyper_4_11_chunk | temp | {17.1,89.5} | -1
_hyper_4_11_chunk | time | {"Thu Apr 20 16:00:01 2017","Fri Apr 21 16:00:01 2017"} | -1
_hyper_4_12_chunk | temp | {11,18.5} | -1
_hyper_4_12_chunk | time | {"Tue Jun 20 16:00:01 2017","Wed Jun 21 16:00:01 2017"} | -1
(12 rows)

-- stats should exist on parent hypertable and normal table
SELECT tablename, attname, histogram_bounds, n_distinct FROM pg_stats
WHERE schemaname = 'public'
ORDER BY tablename, attname, array_to_string(histogram_bounds, ',');
tablename | attname | histogram_bounds | n_distinct
--------------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------
analyze_test | temp | {11,17.1,17.5,18.5,19.1,89.5} | -1
analyze_test | time | {"Fri Jan 20 16:00:01 2017","Sat Jan 21 16:00:01 2017","Thu Apr 20 16:00:01 2017","Fri Apr 21 16:00:01 2017","Tue Jun 20 16:00:01 2017","Wed Jun 21 16:00:01 2017"} | -1
vacuum_norm | temp | {11,17.1,17.5,18.5,19.1,89.5} | -1
vacuum_norm | time | {"Fri Jan 20 09:00:01 2017","Sat Jan 21 09:00:01 2017","Thu Apr 20 09:00:01 2017","Fri Apr 21 09:00:01 2017","Tue Jun 20 09:00:01 2017","Wed Jun 21 09:00:01 2017"} | -1
vacuum_test | temp | {11,17.1,17.5,18.5,19.1,89.5} | -1
vacuum_test | time | {"Fri Jan 20 16:00:01 2017","Sat Jan 21 16:00:01 2017","Thu Apr 20 16:00:01 2017","Fri Apr 21 16:00:01 2017","Tue Jun 20 16:00:01 2017","Wed Jun 21 16:00:01 2017"} | -1
(6 rows)