mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-31 01:15:18 +08:00
VACUUM VERBOSE is the source for flaky tests and we don't gain much by including the verbose output in the test. Additionally removing the verbose option prevents us from having to make the vacuum tests pg-version specific as PG14 slightly changes the formatting of the VACUUM VERBOSE output.
225 lines
15 KiB
Plaintext
225 lines
15 KiB
Plaintext
-- This file and its contents are licensed under the Apache License 2.0.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- 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, create_default_indexes => false);
|
|
NOTICE: adding not-null constraint to column "time"
|
|
create_hypertable
|
|
--------------------------
|
|
(1,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);
|
|
-- 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' AND tablename LIKE 'vacuum_test'
|
|
ORDER BY tablename, attname, array_to_string(histogram_bounds, ',');
|
|
tablename | attname | histogram_bounds | n_distinct
|
|
-----------+---------+------------------+------------
|
|
(0 rows)
|
|
|
|
VACUUM ANALYZE vacuum_test;
|
|
-- stats should exist for all three 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_1_1_chunk | temp | {17.5,19.1} | -1
|
|
_hyper_1_1_chunk | time | {"Fri Jan 20 16:00:01 2017","Sat Jan 21 16:00:01 2017"} | -1
|
|
_hyper_1_2_chunk | temp | {17.1,89.5} | -1
|
|
_hyper_1_2_chunk | time | {"Thu Apr 20 16:00:01 2017","Fri Apr 21 16:00:01 2017"} | -1
|
|
_hyper_1_3_chunk | temp | {11,18.5} | -1
|
|
_hyper_1_3_chunk | time | {"Tue Jun 20 16:00:01 2017","Wed Jun 21 16:00:01 2017"} | -1
|
|
(6 rows)
|
|
|
|
-- stats should exist on parent hypertable
|
|
SELECT tablename, attname, histogram_bounds, n_distinct FROM pg_stats
|
|
WHERE schemaname = 'public' AND tablename LIKE 'vacuum_test'
|
|
ORDER BY tablename, attname, array_to_string(histogram_bounds, ',');
|
|
tablename | attname | histogram_bounds | n_distinct
|
|
-------------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------
|
|
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
|
|
(2 rows)
|
|
|
|
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, create_default_indexes => false);
|
|
NOTICE: adding not-null constraint to column "time"
|
|
create_hypertable
|
|
---------------------------
|
|
(2,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);
|
|
-- 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' AND tablename LIKE 'analyze_test'
|
|
ORDER BY tablename, attname, array_to_string(histogram_bounds, ',');
|
|
tablename | attname | histogram_bounds | n_distinct
|
|
-----------+---------+------------------+------------
|
|
(0 rows)
|
|
|
|
ANALYZE VERBOSE analyze_test;
|
|
INFO: analyzing "_timescaledb_internal._hyper_2_4_chunk"
|
|
INFO: "_hyper_2_4_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
|
|
INFO: analyzing "_timescaledb_internal._hyper_2_5_chunk"
|
|
INFO: "_hyper_2_5_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
|
|
INFO: analyzing "_timescaledb_internal._hyper_2_6_chunk"
|
|
INFO: "_hyper_2_6_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
|
|
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_2_4_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
|
|
INFO: "_hyper_2_5_chunk": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
|
|
INFO: "_hyper_2_6_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 three 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_2_4_chunk | temp | {17.5,19.1} | -1
|
|
_hyper_2_4_chunk | time | {"Fri Jan 20 16:00:01 2017","Sat Jan 21 16:00:01 2017"} | -1
|
|
_hyper_2_5_chunk | temp | {17.1,89.5} | -1
|
|
_hyper_2_5_chunk | time | {"Thu Apr 20 16:00:01 2017","Fri Apr 21 16:00:01 2017"} | -1
|
|
_hyper_2_6_chunk | temp | {11,18.5} | -1
|
|
_hyper_2_6_chunk | time | {"Tue Jun 20 16:00:01 2017","Wed Jun 21 16:00:01 2017"} | -1
|
|
(6 rows)
|
|
|
|
-- stats should exist on parent hypertable
|
|
SELECT tablename, attname, histogram_bounds, n_distinct FROM pg_stats
|
|
WHERE schemaname = 'public' AND tablename LIKE 'analyze_test'
|
|
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
|
|
(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),
|
|
('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);
|
|
VACUUM ANALYZE vacuum_norm;
|
|
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 ANALYZE vacuum_norm, vacuum_test, analyze_test;
|
|
-- 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)
|
|
|