【问题标题】:Not able to take backup of hypertable TimescaleDB database using pg_dump PostgreSQL无法使用 pg_dump PostgreSQL 备份超表 TimescaleDB 数据库
【发布时间】:2021-02-05 06:00:09
【问题描述】:

用于备份的命令

C:\Program Files\PostgreSQL\12\bin>pg_dump  -h localhost -U postgres -p 5432  -Fc -f "D:\Database Backup\temp_10.bak" GESEMS_Performace_Test.

错误:

pg_dump:注意:超表数据在块中,不会复制任何数据。

详细信息:超表的数据存储在超表的块中,因此超表的 COPY TO 将 不复制任何数据。

对 TimescaleDB 超表备份有何建议?

【问题讨论】:

  • 这只是一个通知。您是否确认备份不在转储文件中?

标签: postgresql timescaledb


【解决方案1】:

在 TimescaleDB 中,超表是一个空表,数据存储在称为 chunks 的子表中。可以使用psql中的\d+命令查看超表的结构:

postgres=# \d+ devices
                                          Table "public.devices"
 Column |           Type           | Collation | Nullable | Default | Storage | Stats target | Description 
--------+--------------------------+-----------+----------+---------+---------+--------------+-------------
 time   | timestamp with time zone |           | not null |         | plain   |              | 
 device | integer                  |           | not null |         | plain   |              | 
 temp   | double precision         |           |          |         | plain   |              | 
Indexes:
    "devices_pkey" PRIMARY KEY, btree ("time", device)
    "devices_device_time_idx" btree (device, "time" DESC)
    "devices_time_idx" btree ("time" DESC)
Triggers:
    ts_insert_blocker BEFORE INSERT ON devices FOR EACH ROW EXECUTE FUNCTION _timescaledb_internal.insert_blocker()
Child tables: _timescaledb_internal._dist_hyper_1_10_chunk,
              _timescaledb_internal._dist_hyper_1_11_chunk,
              _timescaledb_internal._dist_hyper_1_12_chunk,
              _timescaledb_internal._dist_hyper_1_13_chunk,
              _timescaledb_internal._dist_hyper_1_14_chunk,
              _timescaledb_internal._dist_hyper_1_15_chunk,
              _timescaledb_internal._dist_hyper_1_1_chunk,
              _timescaledb_internal._dist_hyper_1_2_chunk,
              _timescaledb_internal._dist_hyper_1_3_chunk,
              _timescaledb_internal._dist_hyper_1_4_chunk,
              _timescaledb_internal._dist_hyper_1_5_chunk,
              _timescaledb_internal._dist_hyper_1_6_chunk,
              _timescaledb_internal._dist_hyper_1_7_chunk,
              _timescaledb_internal._dist_hyper_1_8_chunk,
              _timescaledb_internal._dist_hyper_1_9_chunk

当您使用 PostgreSQL pg_dump 转储表时,它将分别转储父表和子表的内容。当您恢复转储时,它将依次填充超表(父表)和块(子表)。

由于pg_dump 在转储时使用标准的COPY 命令来提取表的内容,TimescaleDB 会打印一条通知,指出您正在尝试转储一个空的超表。

这样做的原因是,如果您使用COPY 直接转储超表,它根本不会转储任何数据,这很有用,因为它很容易制作否则是一个错误。由于无法区分您直接在单个表上运行COPY 和使用pg_dump(转储所有表)的情况,因此当您使用pg_dump 时也会打印此通知,但它是无害。

您应该检查实际的转储输出以查看子表是否实际被转储。

【讨论】:

    猜你喜欢
    • 2015-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多