TimescaleDB 提供了许多 SQL 函数和视图,以帮助您与数据进行交互和管理数据。请查看下面的完整列表,或按关键字搜索以查找特定 API 的参考文档。

超表和数据块

hypertable_detailed_size
获取有关超表使用的磁盘空间的详细信息
hypertable_size
获取超表使用的总磁盘空间
add_dimension
向超表添加空间分区维度
add_dimension
向超表添加空间分区维度
add_reorder_policy
添加策略以重新排序超表数据块中的行
attach_tablespace
将表空间附加到超表
chunks_detailed_size
获取有关数据块使用的磁盘空间的详细信息
create_hypertable
创建超表
create_hypertable
创建超表
CREATE INDEX(每个数据块事务)
使用单独的事务为每个数据块创建超表索引
detach_tablespace
从超表分离表空间
detach_tablespaces
从超表分离所有表空间
disable_chunk_skipping
禁用来自超表的数据块列的范围跟踪
enable_chunk_skipping
启用来自超表的数据块列的范围跟踪
hypertable_approximate_detailed_size
获取有关超表使用的近似磁盘空间的详细信息
hypertable_approximate_size
获取超表使用的近似总磁盘空间
hypertable_detailed_size
获取有关超表使用的磁盘空间的详细信息
hypertable_index_size
获取超表索引使用的磁盘空间
hypertable_size
获取超表使用的总磁盘空间
move_chunk
将数据块及其索引移动到不同的表空间
remove_reorder_policy
从超表删除重新排序策略
reorder_chunk
重新排序数据块中的行
set_chunk_time_interval
更改超表的数据块时间间隔
set_integer_now_fun
定义整数时间值和实际时间之间的关系
show_chunks
显示属于超表的数据块
show_tablespaces
显示附加到超表的表空间

连续聚合

add_continuous_aggregate_policy
添加策略以计划自动刷新连续聚合
add_policies
在连续聚合上添加刷新、压缩和数据保留策略
ALTER MATERIALIZED VIEW(连续聚合)
更改现有连续聚合
alter_policies
更改连续聚合上的刷新、压缩或数据保留策略
cagg_migrate
将连续聚合从旧格式迁移到 TimescaleDB 2.7 中引入的新格式
CREATE MATERIALIZED VIEW(连续聚合)
在超表或另一个连续聚合上创建连续聚合
DROP MATERIALIZED VIEW(连续聚合)
删除连续聚合视图
refresh_continuous_aggregate
手动刷新连续聚合
remove_all_policies
从连续聚合中删除所有策略
remove_continuous_aggregate_policy
从连续聚合中删除刷新策略
remove_policies
从连续聚合中删除刷新、压缩或数据保留策略
show_policies
显示当前在连续聚合上设置的所有策略

压缩

add_compression_policy
添加策略以计划数据块的自动压缩
ALTER TABLE(压缩)
更改压缩超表上的压缩设置
chunk_compression_stats
获取数据块的压缩相关统计信息
compress_chunk
手动压缩给定的数据块
decompress_chunk
解压缩压缩的数据块
hypertable_compression_stats
获取与压缩相关的超表统计信息
recompress_chunk
重新压缩在压缩后插入新数据的数据块
remove_compression_policy
从超表删除压缩策略

数据保留

add_retention_policy
添加策略以删除较旧的数据块
remove_retention_policy
从超表删除保留策略
drop_chunks
按时间范围删除数据块

超级函数:降采样

asap_smooth
使用 ASAP 平滑算法对时间序列进行降采样
gp_lttb
使用最大三角形三桶法对时间序列进行降采样,同时保留原始数据中的间隙
lttb
使用最大三角形三桶法对时间序列进行降采样

超级函数:饱和数学

saturating_add
将两个数字相加,在 32 位整数边界处饱和而不是溢出
saturating_add_pos
将两个数字相加,在最小边界处饱和为 0
saturating_mul
将两个数字相乘,在 32 位整数边界处饱和而不是溢出
saturating_sub
从另一个数字中减去一个数字,在 32 位整数边界处饱和而不是溢出
saturating_sub_pos
从另一个数字中减去一个数字,在最小边界处饱和为 0

超级函数:财务分析:candlestick_agg()

close
从烛台聚合获取收盘价
candlestick_agg
将报价数据聚合为中间形式以进行进一步计算
candlestick
将预聚合的烛台数据转换为与 candlestick_agg 函数一起使用的正确形式
close_time
从烛台聚合获取对应于收盘时间的时间戳
high
从烛台聚合获取最高价
high_time
从烛台聚合获取对应于最高时间的时间戳
low
从烛台聚合获取最低价
open
从烛台聚合获取开盘价
low_time
从烛台聚合获取对应于最低时间的时间戳
open_time
从烛台聚合获取对应于开盘时间的时间戳
rollup
汇总多个烛台聚合
volume
从烛台聚合获取总成交量
vwap
从烛台聚合获取成交量加权平均价

超级函数:状态跟踪:compact_state_agg()

compact_state_agg
将状态数据聚合为状态聚合以进行进一步分析
duration_in
从状态聚合计算在给定状态下花费的总时间
interpolated_duration_in
从状态聚合计算在给定状态下花费的总时间,在时间桶边界处插值
into_values
将状态聚合展开为一组行,显示每个状态的持续时间
rollup
Combine multiple state aggregates

超级函数:频率分析:count_min_sketch()

approx_count
CountMinSketch 估计值出现的次数
count_min_sketch
将数据聚合到 CountMinSketch 中以进行近似计数

超级函数:计数器和仪表:counter_agg()

counter_agg
将计数器数据聚合为中间形式以进行进一步分析
corr
从计数器聚合计算相关系数
counter_zero_time
计算预测计数器值为零的时间
delta
从计数器聚合计算计数器的变化量
extrapolated_delta
从计数器聚合计算外推变化量
extrapolated_rate
从计数器聚合计算外推变化率
first_time
从计数器聚合获取第一个时间戳
first_val
从计数器聚合获取第一个值
idelta_left
计算计数器聚合的左边缘或最早边缘的瞬时变化量
idelta_right
计算计数器聚合的右边缘或最晚边缘的瞬时变化量
intercept
从计数器聚合计算 y 轴截距
interpolated_delta
计算计数器的变化量,根据需要插值边界处的值
interpolated_rate
计算计数器的变化率,根据需要插值边界处的值
irate_left
计算计数器聚合的左边缘或最早边缘的瞬时变化率
irate_right
计算计数器聚合的右边缘或最晚边缘的瞬时变化率
last_time
从计数器聚合获取最后一个时间戳
last_val
从计数器聚合获取最后一个值
num_changes
从计数器聚合获取计数器更改的次数
num_elements
从计数器聚合获取具有不同时间戳的点数
num_resets
从计数器聚合获取计数器重置的次数
rate
从计数器聚合计算变化率
rollup
Combine multiple counter aggregates
slope
从计数器聚合计算斜率
time_delta
从计数器聚合计算第一个时间和最后一个时间之间的差值
with_bounds
向计数器聚合添加边界

Hyperfunctions: frequency analysis: freq_agg()

freq_agg
将数据聚合到节省空间的聚合中以进行进一步的频率分析
into_values
Get a table of all frequency estimates from a space-saving aggregate
max_frequency
获取节省空间的聚合中给定值的估计频率的最大边界
mcv_agg
将数据聚合到节省空间的聚合中,以进一步计算最频繁的值
min_frequency
获取节省空间的聚合中给定值的估计频率的最小边界
rollup
Combine multiple frequency aggregates
topn
从节省空间的聚合中获取前 N 个最常见的值

超级函数:计数器和仪表:gauge_agg()

corr
Calculate the correlation coefficient from a gauge aggregate
delta
Calculate the change in a gauge from a gauge aggregate
extrapolated_delta
Calculate the extrapolated change from a gauge aggregate
extrapolated_rate
Calculate the extrapolated rate of change from a gauge aggregate
gauge_agg
将仪表数据聚合为中间形式以进行进一步分析
gauge_zero_time
计算预测仪表值为零的时间
idelta_left
Calculate the instantaneous change at the left, or earliest, edge of a gauge aggregate
idelta_right
Calculate the instantaneous change at the right, or latest, edge of a gauge aggregate
intercept
Calculate the y-intercept from a gauge aggregate
interpolated_delta
Calculate the change in a gauge, interpolating values at boundaries as needed
interpolated_rate
Calculate the rate of change in a gauge, interpolating values at boundaries as needed
irate_left
Calculate the instantaneous rate of change at the left, or earliest, edge of a gauge aggregate
irate_right
Calculate the instantaneous rate of change at the right, or latest, edge of a gauge aggregate
num_changes
Get the number of times a gauge changed from a gauge aggregate
num_elements
Get the number of points with distinct timestamps from a gauge aggregate
rate
Calculate the rate of change from a gauge aggregate
rollup
Combine multiple gauge aggregates
slope
Calculate the slope from a gauge aggregate
time_delta
Calculate the difference between the first and last times from a gauge aggregate
with_bounds
Add bounds to a gauge aggregate

超级函数:状态跟踪:heartbeat_agg()

dead_ranges
从 heartbeat_agg 获取停机间隔
downtime
获取心跳聚合期间的总停机时间
heartbeat_agg
从一组心跳创建活跃度聚合
interpolate
使用前置信息调整心跳聚合
interpolated_downtime
从心跳聚合和前置信息获取总停机时间
interpolated_uptime
从心跳聚合和前置信息获取总正常运行时间
live_at
测试聚合是否具有覆盖给定时间的心跳
live_ranges
从 heartbeat_agg 获取活动间隔
num_gaps
计算活动间隔之间的间隙数
num_live_ranges
计算活动间隔数
rollup
Combine multiple heartbeat aggregates
trim_to
减少心跳聚合的覆盖间隔
uptime
获取心跳聚合期间的总正常运行时间

超级函数:近似去重计数:hyperloglog()

approx_count_distinct
将数据聚合到 hyperloglog 中以进行近似计数,而无需指定桶数
distinct_count
从 hyperloglog 估计不同值的数量
hyperloglog
将数据聚合到 hyperloglog 中以进行近似计数
rollup
Roll up multiple hyperloglogs
stderror
估计 hyperloglog 的相对标准误差

超级函数:最小值和最大值:max_n()

into_array
从 MaxN 聚合返回最高值的数组
into_values
Returns the highest values from a MaxN aggregate
max_n
查找数据集中的最大值
rollup
Combine multiple MaxN aggregates

超级函数:最小值和最大值:max_n_by()

into_values
Returns the highest values and associated data from a MaxNBy aggregate
max_n_by
跟踪一组值中的最大值和关联数据
rollup
Combine multiple MaxNBy aggregates

超级函数:最小值和最大值:min_n()

into_array
从 MinN 聚合返回最低值的数组
into_values
Returns the lowest values from a MinN aggregate
min_n
查找数据集中的最小值
rollup
Combine multiple MinN aggregates

超级函数:最小值和最大值:min_n_by()

into_values
Returns the lowest values and associated data from a MinNBy aggregate
min_n_by
跟踪一组值中的最小值和关联数据
rollup
Combine multiple MinNBy aggregates

超级函数:状态跟踪:state_agg()

duration_in
从状态聚合计算在给定状态下花费的总时间
interpolated_duration_in
从状态聚合计算在给定状态下花费的总时间,在时间桶边界处插值
interpolated_state_periods
从状态聚合获取与给定状态对应的时间段,在时间桶边界处插值
interpolated_state_timeline
从状态聚合获取所有状态的状态,在时间桶边界处插值
into_values
Expand the state aggregate into a set of rows, displaying the duration of each state
rollup
Combine multiple state aggregates
state_at
确定给定时间的状态
state_periods
从状态聚合获取与给定状态对应的时间段
state_timeline
从状态聚合获取所有状态的状态
state_agg
将状态数据聚合为状态聚合以进行进一步分析

超级函数:统计和回归分析:stats_agg()(一个变量)

average
从一维统计聚合计算平均值
kurtosis
从一维统计聚合计算峰度
num_vals
计算一维统计聚合中的值数量
rollup
Combine multiple one-dimensional statistical aggregates
rolling
组合多个一维统计聚合以计算滚动窗口聚合
skewness
从一维统计聚合计算偏度
stats_agg (one variable)
将数据聚合为中间统计聚合形式以进行进一步计算
stddev
从一维统计聚合计算标准差
sum
从一维统计聚合计算总和
variance
从一维统计聚合计算方差

超级函数:百分位数近似:tdigest()

approx_percentile
tdigest 估计给定百分位数的值
approx_percentile_rank
tdigest 估计给定值的百分位数
mean
tdigest 中的值计算精确平均值
num_vals
Get the number of values contained in a tdigest
rollup
Roll up multiple tdigests
tdigest
tdigest 中聚合数据以进一步计算百分位数估计值

超级函数:统计和回归分析:stats_agg()(两个变量)

average_y, average_x
从二维统计聚合计算指定维度的平均值
corr
Calculate the correlation coefficient from a two-dimensional statistical aggregate
covariance
从二维统计聚合计算协方差
determination_coeff
从二维统计聚合计算决定系数
intercept
Calculate the intercept from a two-dimensional statistical aggregate
kurtosis_y, kurtosis_x
计算二维统计聚合中指定维度的峰度
num_vals
Calculate the number of values in a two-dimensional statistical aggregate
rolling
Combine multiple two-dimensional statistical aggregates to calculate rolling window aggregates
rollup
Combine multiple two-dimensional statistical aggregates
skewness_y, skewness_x
计算二维统计聚合中指定维度的偏度
slope
Calculate the slope from a two-dimensional statistical aggregate
stats_agg (two variables)
将数据聚合为中间统计聚合形式以进行进一步计算
stddev_y, stddev_x
计算二维统计聚合中指定维度的标准差
sum_y, sum_x
计算二维统计聚合中指定维度的总和
variance_y, variance_x
计算二维统计聚合中指定维度的方差
x_intercept
从二维统计聚合计算 x 轴截距

Hyperfunctions: gapfilling

interpolate
通过线性插值填充缺失值
locf
通过向前结转最后观察到的值来填充缺失值
time_bucket_gapfill
按时间间隔对行进行分桶,同时填充数据中的间隙

超级函数:百分位数近似:uddsketch()

approx_percentile
Estimate the value at a given percentile from a uddsketch
approx_percentile_array
uddsketch 估计给定百分位数数组的值
approx_percentile_rank
Estimate the percentile of a given value from a uddsketch
error
获取 uddsketch 的最大相对误差
mean
Calculate the exact mean from values in a uddsketch
num_vals
Get the number of values contained in a uddsketch
percentile_agg
在 uddsketch 中聚合数据,使用一些合理的默认值,以进一步计算百分位数估计值
rollup
Roll up multiple uddsketches
uddsketch
uddsketch 中聚合数据以进一步计算百分位数估计值

超级函数:时间加权计算:time_weight()

average
Calculate the time-weighted average of values in a TimeWeightSummary
first_time
Get the first timestamp from a TimeWeightSummary aggregate
first_val
Get the first value from a TimeWeightSummary aggregate
integral
TimeWeightSummary 计算积分
interpolated_average
计算时间间隔内的加权平均值,同时插值间隔边界
interpolated_integral
计算时间间隔内的积分,同时插值间隔边界
last_time
Get the last timestamp from a TimeWeightSummary aggregate
last_val
Get the last value from a TimeWeightSummary aggregate
rollup
Combine multiple TimeWeightSummaries
time_weight
将数据聚合为中间时间加权聚合形式以进行进一步计算

操作和自动化

add_job
添加作业以自动运行用户定义的操作
alter_job
更改计划自动运行的作业
delete_job
从自动调度程序中删除作业
run_job
手动运行作业

分布式超表

add_data_node
向多节点集群添加新的数据节点
alter_data_node
更改数据节点的配置
attach_data_node
将数据节点附加到分布式超表
cleanup_copy_chunk_operation
清理失败的数据块移动或数据块复制操作后遗留的数据
copy_chunk
在分布式超表中的数据节点之间复制数据块
create_distributed_hypertable
在多节点集群中创建分布式超表
create_distributed_restore_point
为多节点集群中的所有节点创建一致的还原点
delete_data_node
从数据库中删除数据节点并将其从所有超表中分离
detach_data_node
从一个或所有超表分离数据节点
distributed_exec
跨多节点集群的所有数据节点执行过程
move_chunk
Move a chunk to a different data node in a multi-node cluster
set_number_partitions
设置超表的哈希分区数
set_replication_factor
设置分布式超表的复制因子

超级函数:通用

approximate_row_count
估计表中的行数
days_in_month
计算给定 timestamptz 的月份天数
first
当行按另一列排序时,获取一列中的第一个值
histogram
将数据集划分为桶,并获取每个桶中的计数数
last
当行按另一列排序时,获取一列中的最后一个值
month_normalize
根据月份天数标准化每月指标
time_bucket
按时间间隔对行进行分桶以计算聚合
timescaledb_experimental.time_bucket_ng
按时间间隔对行进行分桶,并支持时区、月份和年份

信息视图

timescaledb_information.chunk_compression_settings
获取有关所有数据块的压缩设置的信息
timescaledb_information.chunks
获取有关超表数据块的元数据
timescaledb_information.compression_settings
获取有关超表的压缩设置的信息
timescaledb_information.continuous_aggregates
获取有关连续聚合的元数据和设置信息
timescaledb_information.data_nodes
获取有关多节点集群中数据节点的信息
timescaledb_information.dimensions
获取有关超表的维度的信息
timescaledb_information.hypertable_compression_settings
获取有关所有超表的压缩设置的信息
timescaledb_information.hypertables
获取有关超表的元数据
timescaledb_information.job_stats
获取有关自动运行作业的信息和统计信息
timescaledb_information.jobs
获取有关自动调度程序注册的所有作业的信息
timescaledb_experimental.policies
获取有关连续聚合上设置的所有策略的信息

其他

timescaledb_information.job_errors
获取有关后台作业错误的信息
timescaledb_information.history
获取有关后台作业执行的信息

关键词

在此页面上发现问题?报告问题 或 在 GitHub 上编辑此页