mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 18:43:18 +08:00
Users can now (optionally) set a target chunk size and TimescaleDB will try to adapt the interval length of the first open ("time") dimension in order to reach that target chunk size. If a hypertable has more than one open dimension, only the first one will have a dynamically adapting interval. Users can optionally specify their own function that calculates the new dimension interval. They can also set a target size of 0 in order to estimate a suitable target size for a chunk based on available memory.
33 lines
1.5 KiB
SQL
33 lines
1.5 KiB
SQL
CREATE OR REPLACE FUNCTION _timescaledb_internal.dimension_calculate_default_range_open(
|
|
dimension_value BIGINT,
|
|
interval_length BIGINT,
|
|
OUT range_start BIGINT,
|
|
OUT range_end BIGINT)
|
|
AS '@MODULE_PATHNAME@', 'dimension_calculate_open_range_default' LANGUAGE C STABLE;
|
|
|
|
CREATE OR REPLACE FUNCTION _timescaledb_internal.dimension_calculate_default_range_closed(
|
|
dimension_value BIGINT,
|
|
num_slices SMALLINT,
|
|
OUT range_start BIGINT,
|
|
OUT range_end BIGINT)
|
|
AS '@MODULE_PATHNAME@', 'dimension_calculate_closed_range_default' LANGUAGE C STABLE;
|
|
|
|
-- Built-in function for calculating the next chunk interval when
|
|
-- using adaptive chunking. The function can be replaced by a
|
|
-- user-defined function with the same signature.
|
|
--
|
|
-- The parameters passed to the function are as follows:
|
|
--
|
|
-- dimension_id: the ID of the dimension to calculate the interval for
|
|
-- dimension_coord: the coordinate / point on the dimensional axis
|
|
-- where the tuple that triggered this chunk creation falls.
|
|
-- chunk_target_size: the target size in bytes that the chunk should have.
|
|
--
|
|
-- The function should return the new interval in dimension-specific
|
|
-- time (ususally microseconds).
|
|
CREATE OR REPLACE FUNCTION _timescaledb_internal.calculate_chunk_interval(
|
|
dimension_id INTEGER,
|
|
dimension_coord BIGINT,
|
|
chunk_target_size BIGINT
|
|
) RETURNS BIGINT AS '@MODULE_PATHNAME@', 'calculate_chunk_interval' LANGUAGE C;
|