从一个空数据库开始

One of the core ideas of our time-series database is the time-series optimized data table we call a ​hypertable​.

我们的时间序列数据库的核心理念之一就是时间序列的数据优化表--hypertable。

创建一个(Hyper)table

To create a hypertable, you start with a regular SQL table, and then convert it into a hypertable via the function ​create_hypertable()​.

创建一个普通的SQL表,使用​create_hypertable()函数将SQL表转化为hypertable。

The following example creates a hypertable for tracking temperature and humidity across a collection of devices over time.

以下示例创建了一个随着时间推移记录温度和湿度的hypertable。


-- We start by creating a regular SQL table
--创建一个普通的SQL表

CREATE TABLE conditions (
  time        TIMESTAMPTZ       NOT NULL,
  location    TEXT              NOT NULL,
  temperature DOUBLE PRECISION  NULL,
  humidity    DOUBLE PRECISION  NULL
);

Next, transform it into a hypertable with ​create_hypertable()​:

接下来,使用create_hypertable()​将SQL表转化为hyper table。

-- This creates a hypertable that is partitioned by time
--创建了一个根据时间分区的hypertable。
--   using the values in the `time` column.
--使用`time`列的数值。

SELECT create_hypertable('conditions', 'time');

-- OR you can additionally partition the data on another
--   dimension (what we call 'space partitioning').
--或者增加其他维度来分割数据(我们叫做“空间分区”)。
-- E.g., to partition `location` into 4 partitions:
--例如,将`location`分成4个区块:

SELECT create_hypertable('conditions', 'time', 'location', 4);

For more information about how to choose the appropriate partitioning for your data, see our ​best practices discussion​. ​Next let's learn how to create and work with a ​hypertable​, the primary point of interaction for TimescaleDB.​

更多合理分割数据的方法请参见我们最好的实践讨论。

results matching ""

    No results matching ""