Rename {enable|disable}_column_stats API

For better understanding we've decided to rename the public API from
`{enable|disable}_column_stats` to `{enable|disable}_chunk_skipping`.
This commit is contained in:
Fabrízio de Royes Mello 2024-07-25 20:00:54 -03:00
parent 554957cc19
commit a4a023e89a
8 changed files with 94 additions and 94 deletions

View File

@ -156,7 +156,7 @@ AS '@MODULE_PATHNAME@', 'ts_dimension_add_general' LANGUAGE C VOLATILE;
-- if_not_exists - If set, and the entry already exists, generate a notice instead of an error
-- Returns the "id" of the entry created. The "enabled" field
-- is set to true if entry is created or exists already.
CREATE OR REPLACE FUNCTION @extschema@.enable_column_stats(
CREATE OR REPLACE FUNCTION @extschema@.enable_chunk_skipping(
hypertable REGCLASS,
column_name NAME,
if_not_exists BOOLEAN = FALSE
@ -170,7 +170,7 @@ AS '@MODULE_PATHNAME@', 'ts_chunk_column_stats_enable' LANGUAGE C VOLATILE;
-- if_not_exists - If set, and the entry does not exist,
-- generate a notice instead of an error. The "disabled" field
-- is set to true if entry is deleted successfully.
CREATE OR REPLACE FUNCTION @extschema@.disable_column_stats(
CREATE OR REPLACE FUNCTION @extschema@.disable_chunk_skipping(
hypertable REGCLASS,
column_name NAME,
if_not_exists BOOLEAN = FALSE

View File

@ -3,7 +3,7 @@
-- hypertable - OID of the table to which the column belongs to
-- column_name - The column to track statistics for
-- if_not_exists - If set, and the entry already exists, generate a notice instead of an error
CREATE FUNCTION @extschema@.enable_column_stats(
CREATE FUNCTION @extschema@.enable_chunk_skipping(
hypertable REGCLASS,
column_name NAME,
if_not_exists BOOLEAN = FALSE
@ -16,7 +16,7 @@ AS 'SELECT NULL,NULL' LANGUAGE SQL VOLATILE SET search_path = pg_catalog, pg_tem
-- column_name - NAME of the column on which the stats are tracked
-- if_not_exists - If set, and the entry does not exist,
-- generate a notice instead of an error
CREATE FUNCTION @extschema@.disable_column_stats(
CREATE FUNCTION @extschema@.disable_chunk_skipping(
hypertable REGCLASS,
column_name NAME,
if_not_exists BOOLEAN = FALSE

View File

@ -1,7 +1,7 @@
DROP FUNCTION IF EXISTS _timescaledb_functions.cagg_get_bucket_function_info(INTEGER);
-- remove chunk column statistics related objects
DROP FUNCTION IF EXISTS @extschema@.enable_column_stats(REGCLASS, NAME, BOOLEAN);
DROP FUNCTION IF EXISTS @extschema@.disable_column_stats(REGCLASS, NAME, BOOLEAN);
DROP FUNCTION IF EXISTS @extschema@.enable_chunk_skipping(REGCLASS, NAME, BOOLEAN);
DROP FUNCTION IF EXISTS @extschema@.disable_chunk_skipping(REGCLASS, NAME, BOOLEAN);
ALTER EXTENSION timescaledb DROP TABLE _timescaledb_catalog.chunk_column_stats;
ALTER EXTENSION timescaledb DROP SEQUENCE _timescaledb_catalog.chunk_column_stats_id_seq;
DROP TABLE IF EXISTS _timescaledb_catalog.chunk_column_stats;

View File

@ -51,21 +51,21 @@ INSERT INTO sample_table VALUES (:'start_date'::timestamptz, 16, 14.6554, 47, 'n
-- Non-int, date, timestamp cannot be specified as a min/max ranges for now
-- We could expand to FLOATs, NUMERICs later
\set ON_ERROR_STOP 0
SELECT * FROM enable_column_stats('sample_table', 'name');
SELECT * FROM enable_chunk_skipping('sample_table', 'name');
ERROR: data type "character varying" unsupported for range calculation
SELECT * FROM enable_column_stats('sample_table', NULL);
SELECT * FROM enable_chunk_skipping('sample_table', NULL);
ERROR: column name cannot be NULL
SELECT * FROM enable_column_stats(NULL, 'name');
SELECT * FROM enable_chunk_skipping(NULL, 'name');
ERROR: hypertable cannot be NULL
SELECT * FROM enable_column_stats('sample_table1', 'name');
ERROR: relation "sample_table1" does not exist at character 35
SELECT * FROM enable_chunk_skipping('sample_table1', 'name');
ERROR: relation "sample_table1" does not exist at character 37
CREATE TABLE plain_table(like sample_table);
SELECT * FROM enable_column_stats('plain_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('plain_table', 'sensor_id');
ERROR: table "plain_table" is not a hypertable
DROP TABLE plain_table;
\set ON_ERROR_STOP 1
-- Specify tracking of min/max ranges for a column
SELECT * FROM enable_column_stats('sample_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id');
column_stats_id | enabled
-----------------+---------
1 | t
@ -82,7 +82,7 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
(3 rows)
-- Skipping should work
SELECT * FROM enable_column_stats('sample_table', 'sensor_id', true);
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id', true);
NOTICE: already enabled for column "sensor_id", skipping
column_stats_id | enabled
-----------------+---------
@ -334,8 +334,8 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
-- Check that a RENAME COLUMN works ok
ALTER TABLE sample_table RENAME COLUMN sensor_id TO sense_id;
-- use the disable_column_stats API to remove the min/max range entries
SELECT * from disable_column_stats('sample_table', 'sense_id');
-- use the disable_chunk_skipping API to remove the min/max range entries
SELECT * from disable_chunk_skipping('sample_table', 'sense_id');
hypertable_id | column_name | disabled
---------------+-------------+----------
1 | sense_id | t
@ -346,7 +346,7 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
----+---------------+----------+-------------+-------------+-----------+-------
(0 rows)
SELECT * from disable_column_stats('sample_table', 'sense_id', true);
SELECT * from disable_chunk_skipping('sample_table', 'sense_id', true);
NOTICE: statistics not enabled for column "sense_id", skipping
hypertable_id | column_name | disabled
---------------+-------------+----------
@ -355,21 +355,21 @@ NOTICE: statistics not enabled for column "sense_id", skipping
ALTER TABLE sample_table RENAME COLUMN sense_id TO sensor_id;
\set ON_ERROR_STOP 0
SELECT * from disable_column_stats('sample_table', 'sensor_id');
SELECT * from disable_chunk_skipping('sample_table', 'sensor_id');
ERROR: statistics not enabled for column "sensor_id"
SELECT * from disable_column_stats('sample_table', NULL);
SELECT * from disable_chunk_skipping('sample_table', NULL);
ERROR: column name cannot be NULL
SELECT * from disable_column_stats(NULL, 'sensor_id');
SELECT * from disable_chunk_skipping(NULL, 'sensor_id');
ERROR: hypertable cannot be NULL
SELECT * from disable_column_stats('sample_table1', 'sensor_id');
ERROR: relation "sample_table1" does not exist at character 36
SELECT * from disable_chunk_skipping('sample_table1', 'sensor_id');
ERROR: relation "sample_table1" does not exist at character 38
-- should only work on columns that have been enabled for tracking
SELECT * from disable_column_stats('sample_table', 'time');
SELECT * from disable_chunk_skipping('sample_table', 'time');
ERROR: statistics not enabled for column "time"
SELECT * from disable_column_stats('sample_table', 'cpu');
SELECT * from disable_chunk_skipping('sample_table', 'cpu');
ERROR: statistics not enabled for column "cpu"
\set ON_ERROR_STOP 1
SELECT * FROM enable_column_stats('sample_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id');
column_stats_id | enabled
-----------------+---------
5 | t
@ -485,7 +485,7 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
----+---------------+----------+-------------+-------------+-----------+-------
(0 rows)
-- Check that empty hypertables can have enable_column_stats and
-- Check that empty hypertables can have enable_chunk_skipping and
-- that new chunks get entries in the catalog as they get added
CREATE TABLE sample_table1 (
time TIMESTAMP WITH TIME ZONE NOT NULL,
@ -503,7 +503,7 @@ WARNING: column type "character varying" used for "name" does not follow best p
3 | public | sample_table1 | t
(1 row)
SELECT * FROM enable_column_stats('sample_table1', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table1', 'sensor_id');
column_stats_id | enabled
-----------------+---------
9 | t
@ -534,7 +534,7 @@ ERROR: column "sensor_id" cannot be cast automatically to type timestamp with t
ALTER TABLE sample_table1 ALTER COLUMN sensor_id TYPE TEXT;
ERROR: data type "text" unsupported for statistics calculation
\set ON_ERROR_STOP 1
SELECT * FROM disable_column_stats('sample_table1', 'sensor_id');
SELECT * FROM disable_chunk_skipping('sample_table1', 'sensor_id');
hypertable_id | column_name | disabled
---------------+-------------+----------
3 | sensor_id | t

View File

@ -51,21 +51,21 @@ INSERT INTO sample_table VALUES (:'start_date'::timestamptz, 16, 14.6554, 47, 'n
-- Non-int, date, timestamp cannot be specified as a min/max ranges for now
-- We could expand to FLOATs, NUMERICs later
\set ON_ERROR_STOP 0
SELECT * FROM enable_column_stats('sample_table', 'name');
SELECT * FROM enable_chunk_skipping('sample_table', 'name');
ERROR: data type "character varying" unsupported for range calculation
SELECT * FROM enable_column_stats('sample_table', NULL);
SELECT * FROM enable_chunk_skipping('sample_table', NULL);
ERROR: column name cannot be NULL
SELECT * FROM enable_column_stats(NULL, 'name');
SELECT * FROM enable_chunk_skipping(NULL, 'name');
ERROR: hypertable cannot be NULL
SELECT * FROM enable_column_stats('sample_table1', 'name');
ERROR: relation "sample_table1" does not exist at character 35
SELECT * FROM enable_chunk_skipping('sample_table1', 'name');
ERROR: relation "sample_table1" does not exist at character 37
CREATE TABLE plain_table(like sample_table);
SELECT * FROM enable_column_stats('plain_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('plain_table', 'sensor_id');
ERROR: table "plain_table" is not a hypertable
DROP TABLE plain_table;
\set ON_ERROR_STOP 1
-- Specify tracking of min/max ranges for a column
SELECT * FROM enable_column_stats('sample_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id');
column_stats_id | enabled
-----------------+---------
1 | t
@ -82,7 +82,7 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
(3 rows)
-- Skipping should work
SELECT * FROM enable_column_stats('sample_table', 'sensor_id', true);
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id', true);
NOTICE: already enabled for column "sensor_id", skipping
column_stats_id | enabled
-----------------+---------
@ -335,8 +335,8 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
-- Check that a RENAME COLUMN works ok
ALTER TABLE sample_table RENAME COLUMN sensor_id TO sense_id;
-- use the disable_column_stats API to remove the min/max range entries
SELECT * from disable_column_stats('sample_table', 'sense_id');
-- use the disable_chunk_skipping API to remove the min/max range entries
SELECT * from disable_chunk_skipping('sample_table', 'sense_id');
hypertable_id | column_name | disabled
---------------+-------------+----------
1 | sense_id | t
@ -347,7 +347,7 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
----+---------------+----------+-------------+-------------+-----------+-------
(0 rows)
SELECT * from disable_column_stats('sample_table', 'sense_id', true);
SELECT * from disable_chunk_skipping('sample_table', 'sense_id', true);
NOTICE: statistics not enabled for column "sense_id", skipping
hypertable_id | column_name | disabled
---------------+-------------+----------
@ -356,21 +356,21 @@ NOTICE: statistics not enabled for column "sense_id", skipping
ALTER TABLE sample_table RENAME COLUMN sense_id TO sensor_id;
\set ON_ERROR_STOP 0
SELECT * from disable_column_stats('sample_table', 'sensor_id');
SELECT * from disable_chunk_skipping('sample_table', 'sensor_id');
ERROR: statistics not enabled for column "sensor_id"
SELECT * from disable_column_stats('sample_table', NULL);
SELECT * from disable_chunk_skipping('sample_table', NULL);
ERROR: column name cannot be NULL
SELECT * from disable_column_stats(NULL, 'sensor_id');
SELECT * from disable_chunk_skipping(NULL, 'sensor_id');
ERROR: hypertable cannot be NULL
SELECT * from disable_column_stats('sample_table1', 'sensor_id');
ERROR: relation "sample_table1" does not exist at character 36
SELECT * from disable_chunk_skipping('sample_table1', 'sensor_id');
ERROR: relation "sample_table1" does not exist at character 38
-- should only work on columns that have been enabled for tracking
SELECT * from disable_column_stats('sample_table', 'time');
SELECT * from disable_chunk_skipping('sample_table', 'time');
ERROR: statistics not enabled for column "time"
SELECT * from disable_column_stats('sample_table', 'cpu');
SELECT * from disable_chunk_skipping('sample_table', 'cpu');
ERROR: statistics not enabled for column "cpu"
\set ON_ERROR_STOP 1
SELECT * FROM enable_column_stats('sample_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id');
column_stats_id | enabled
-----------------+---------
5 | t
@ -486,7 +486,7 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
----+---------------+----------+-------------+-------------+-----------+-------
(0 rows)
-- Check that empty hypertables can have enable_column_stats and
-- Check that empty hypertables can have enable_chunk_skipping and
-- that new chunks get entries in the catalog as they get added
CREATE TABLE sample_table1 (
time TIMESTAMP WITH TIME ZONE NOT NULL,
@ -504,7 +504,7 @@ WARNING: column type "character varying" used for "name" does not follow best p
3 | public | sample_table1 | t
(1 row)
SELECT * FROM enable_column_stats('sample_table1', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table1', 'sensor_id');
column_stats_id | enabled
-----------------+---------
9 | t
@ -535,7 +535,7 @@ ERROR: column "sensor_id" cannot be cast automatically to type timestamp with t
ALTER TABLE sample_table1 ALTER COLUMN sensor_id TYPE TEXT;
ERROR: data type "text" unsupported for statistics calculation
\set ON_ERROR_STOP 1
SELECT * FROM disable_column_stats('sample_table1', 'sensor_id');
SELECT * FROM disable_chunk_skipping('sample_table1', 'sensor_id');
hypertable_id | column_name | disabled
---------------+-------------+----------
3 | sensor_id | t

View File

@ -51,21 +51,21 @@ INSERT INTO sample_table VALUES (:'start_date'::timestamptz, 16, 14.6554, 47, 'n
-- Non-int, date, timestamp cannot be specified as a min/max ranges for now
-- We could expand to FLOATs, NUMERICs later
\set ON_ERROR_STOP 0
SELECT * FROM enable_column_stats('sample_table', 'name');
SELECT * FROM enable_chunk_skipping('sample_table', 'name');
ERROR: data type "character varying" unsupported for range calculation
SELECT * FROM enable_column_stats('sample_table', NULL);
SELECT * FROM enable_chunk_skipping('sample_table', NULL);
ERROR: column name cannot be NULL
SELECT * FROM enable_column_stats(NULL, 'name');
SELECT * FROM enable_chunk_skipping(NULL, 'name');
ERROR: hypertable cannot be NULL
SELECT * FROM enable_column_stats('sample_table1', 'name');
ERROR: relation "sample_table1" does not exist at character 35
SELECT * FROM enable_chunk_skipping('sample_table1', 'name');
ERROR: relation "sample_table1" does not exist at character 37
CREATE TABLE plain_table(like sample_table);
SELECT * FROM enable_column_stats('plain_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('plain_table', 'sensor_id');
ERROR: table "plain_table" is not a hypertable
DROP TABLE plain_table;
\set ON_ERROR_STOP 1
-- Specify tracking of min/max ranges for a column
SELECT * FROM enable_column_stats('sample_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id');
column_stats_id | enabled
-----------------+---------
1 | t
@ -82,7 +82,7 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
(3 rows)
-- Skipping should work
SELECT * FROM enable_column_stats('sample_table', 'sensor_id', true);
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id', true);
NOTICE: already enabled for column "sensor_id", skipping
column_stats_id | enabled
-----------------+---------
@ -335,8 +335,8 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
-- Check that a RENAME COLUMN works ok
ALTER TABLE sample_table RENAME COLUMN sensor_id TO sense_id;
-- use the disable_column_stats API to remove the min/max range entries
SELECT * from disable_column_stats('sample_table', 'sense_id');
-- use the disable_chunk_skipping API to remove the min/max range entries
SELECT * from disable_chunk_skipping('sample_table', 'sense_id');
hypertable_id | column_name | disabled
---------------+-------------+----------
1 | sense_id | t
@ -347,7 +347,7 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
----+---------------+----------+-------------+-------------+-----------+-------
(0 rows)
SELECT * from disable_column_stats('sample_table', 'sense_id', true);
SELECT * from disable_chunk_skipping('sample_table', 'sense_id', true);
NOTICE: statistics not enabled for column "sense_id", skipping
hypertable_id | column_name | disabled
---------------+-------------+----------
@ -356,21 +356,21 @@ NOTICE: statistics not enabled for column "sense_id", skipping
ALTER TABLE sample_table RENAME COLUMN sense_id TO sensor_id;
\set ON_ERROR_STOP 0
SELECT * from disable_column_stats('sample_table', 'sensor_id');
SELECT * from disable_chunk_skipping('sample_table', 'sensor_id');
ERROR: statistics not enabled for column "sensor_id"
SELECT * from disable_column_stats('sample_table', NULL);
SELECT * from disable_chunk_skipping('sample_table', NULL);
ERROR: column name cannot be NULL
SELECT * from disable_column_stats(NULL, 'sensor_id');
SELECT * from disable_chunk_skipping(NULL, 'sensor_id');
ERROR: hypertable cannot be NULL
SELECT * from disable_column_stats('sample_table1', 'sensor_id');
ERROR: relation "sample_table1" does not exist at character 36
SELECT * from disable_chunk_skipping('sample_table1', 'sensor_id');
ERROR: relation "sample_table1" does not exist at character 38
-- should only work on columns that have been enabled for tracking
SELECT * from disable_column_stats('sample_table', 'time');
SELECT * from disable_chunk_skipping('sample_table', 'time');
ERROR: statistics not enabled for column "time"
SELECT * from disable_column_stats('sample_table', 'cpu');
SELECT * from disable_chunk_skipping('sample_table', 'cpu');
ERROR: statistics not enabled for column "cpu"
\set ON_ERROR_STOP 1
SELECT * FROM enable_column_stats('sample_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id');
column_stats_id | enabled
-----------------+---------
5 | t
@ -486,7 +486,7 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
----+---------------+----------+-------------+-------------+-----------+-------
(0 rows)
-- Check that empty hypertables can have enable_column_stats and
-- Check that empty hypertables can have enable_chunk_skipping and
-- that new chunks get entries in the catalog as they get added
CREATE TABLE sample_table1 (
time TIMESTAMP WITH TIME ZONE NOT NULL,
@ -504,7 +504,7 @@ WARNING: column type "character varying" used for "name" does not follow best p
3 | public | sample_table1 | t
(1 row)
SELECT * FROM enable_column_stats('sample_table1', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table1', 'sensor_id');
column_stats_id | enabled
-----------------+---------
9 | t
@ -535,7 +535,7 @@ ERROR: column "sensor_id" cannot be cast automatically to type timestamp with t
ALTER TABLE sample_table1 ALTER COLUMN sensor_id TYPE TEXT;
ERROR: data type "text" unsupported for statistics calculation
\set ON_ERROR_STOP 1
SELECT * FROM disable_column_stats('sample_table1', 'sensor_id');
SELECT * FROM disable_chunk_skipping('sample_table1', 'sensor_id');
hypertable_id | column_name | disabled
---------------+-------------+----------
3 | sensor_id | t

View File

@ -227,9 +227,9 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
delete_job(integer)
detach_tablespace(name,regclass,boolean)
detach_tablespaces(regclass)
disable_column_stats(regclass,name,boolean)
disable_chunk_skipping(regclass,name,boolean)
drop_chunks(regclass,"any","any",boolean,"any","any")
enable_column_stats(regclass,name,boolean)
enable_chunk_skipping(regclass,name,boolean)
first(anyelement,"any")
histogram(double precision,double precision,double precision,integer)
hypertable_approximate_detailed_size(regclass)

View File

@ -54,24 +54,24 @@ INSERT INTO sample_table VALUES (:'start_date'::timestamptz, 16, 14.6554, 47, 'n
-- Non-int, date, timestamp cannot be specified as a min/max ranges for now
-- We could expand to FLOATs, NUMERICs later
\set ON_ERROR_STOP 0
SELECT * FROM enable_column_stats('sample_table', 'name');
SELECT * FROM enable_column_stats('sample_table', NULL);
SELECT * FROM enable_column_stats(NULL, 'name');
SELECT * FROM enable_column_stats('sample_table1', 'name');
SELECT * FROM enable_chunk_skipping('sample_table', 'name');
SELECT * FROM enable_chunk_skipping('sample_table', NULL);
SELECT * FROM enable_chunk_skipping(NULL, 'name');
SELECT * FROM enable_chunk_skipping('sample_table1', 'name');
CREATE TABLE plain_table(like sample_table);
SELECT * FROM enable_column_stats('plain_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('plain_table', 'sensor_id');
DROP TABLE plain_table;
\set ON_ERROR_STOP 1
-- Specify tracking of min/max ranges for a column
SELECT * FROM enable_column_stats('sample_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id');
-- The above should add an entry with MIN/MAX int64 entries for invalid chunk id
-- to indicate that ranges on this column should be calculated for chunks
SELECT * from _timescaledb_catalog.chunk_column_stats;
-- Skipping should work
SELECT * FROM enable_column_stats('sample_table', 'sensor_id', true);
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id', true);
-- A query using a WHERE clause on "sensor_id" column will scan all the chunks
:PREFIX SELECT * FROM sample_table WHERE sensor_id > 9;
@ -159,24 +159,24 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
-- Check that a RENAME COLUMN works ok
ALTER TABLE sample_table RENAME COLUMN sensor_id TO sense_id;
-- use the disable_column_stats API to remove the min/max range entries
SELECT * from disable_column_stats('sample_table', 'sense_id');
-- use the disable_chunk_skipping API to remove the min/max range entries
SELECT * from disable_chunk_skipping('sample_table', 'sense_id');
SELECT * from _timescaledb_catalog.chunk_column_stats;
SELECT * from disable_column_stats('sample_table', 'sense_id', true);
SELECT * from disable_chunk_skipping('sample_table', 'sense_id', true);
ALTER TABLE sample_table RENAME COLUMN sense_id TO sensor_id;
\set ON_ERROR_STOP 0
SELECT * from disable_column_stats('sample_table', 'sensor_id');
SELECT * from disable_column_stats('sample_table', NULL);
SELECT * from disable_column_stats(NULL, 'sensor_id');
SELECT * from disable_column_stats('sample_table1', 'sensor_id');
SELECT * from disable_chunk_skipping('sample_table', 'sensor_id');
SELECT * from disable_chunk_skipping('sample_table', NULL);
SELECT * from disable_chunk_skipping(NULL, 'sensor_id');
SELECT * from disable_chunk_skipping('sample_table1', 'sensor_id');
-- should only work on columns that have been enabled for tracking
SELECT * from disable_column_stats('sample_table', 'time');
SELECT * from disable_column_stats('sample_table', 'cpu');
SELECT * from disable_chunk_skipping('sample_table', 'time');
SELECT * from disable_chunk_skipping('sample_table', 'cpu');
\set ON_ERROR_STOP 1
SELECT * FROM enable_column_stats('sample_table', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table', 'sensor_id');
-- Chunk was already compressed before we enabled stats. It will
-- point to min/max entries till the ranges get refreshed later.
SELECT decompress_chunk(:'CH_NAME');
@ -210,7 +210,7 @@ SELECT * from _timescaledb_catalog.chunk_column_stats;
DROP TABLE sample_table;
SELECT * from _timescaledb_catalog.chunk_column_stats;
-- Check that empty hypertables can have enable_column_stats and
-- Check that empty hypertables can have enable_chunk_skipping and
-- that new chunks get entries in the catalog as they get added
CREATE TABLE sample_table1 (
time TIMESTAMP WITH TIME ZONE NOT NULL,
@ -223,7 +223,7 @@ CREATE INDEX sense_idx ON sample_table1 (sensor_id);
SELECT * FROM create_hypertable('sample_table1', 'time',
chunk_time_interval => INTERVAL '2 months');
SELECT * FROM enable_column_stats('sample_table1', 'sensor_id');
SELECT * FROM enable_chunk_skipping('sample_table1', 'sensor_id');
SELECT * from _timescaledb_catalog.chunk_column_stats;
\set start_date '2023-03-17 17:51:11.322998+05:30'
@ -239,5 +239,5 @@ ALTER TABLE sample_table1 ALTER COLUMN sensor_id TYPE TIMESTAMPTZ;
ALTER TABLE sample_table1 ALTER COLUMN sensor_id TYPE TEXT;
\set ON_ERROR_STOP 1
SELECT * FROM disable_column_stats('sample_table1', 'sensor_id');
SELECT * FROM disable_chunk_skipping('sample_table1', 'sensor_id');
ALTER TABLE sample_table1 ALTER COLUMN sensor_id TYPE TEXT;