TimescaleDB 时序数据库 之四 timescaledb-parallel-copy

os: centos 7.4
db: postgresql 11.6 + timescaledb 1.5.1

timescaledb-parallel-copy 是一个命令行程序,用于并行化 PostgreSQL 的内置 COPY 功能,以将数据批量插入到 TimescaleDB 中。当开始使用 TimescaleDB 时,我们建议将此程序作为获得更好的大容量插入性能的好方法。

该工具的目的是通过 COPYs 同时运行多个文件来加快大型数据的迁移。除了并行化工作负载之外,该工具还提供了一些标记来改善复制体验。

版本

# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core) 
# 
# su - postgres
Last login: Mon Dec 16 20:13:53 CST 2019 on pts/0
-bash-4.2$ psql
psql (11.6)
Type "help" for help.

postgres=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 11.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit
(1 row)

postgres=#

下载安装

# yum install golang
# su - postgres
$ go get github.com/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy
$ cd ./go/bin/
$ ls -l 
total 3000
-rwxrwxr-x 1 postgres postgres 3070633 Apr  9 14:35 timescaledb-parallel-copy

建议可以好好看看 ~/go/src 下面的代码.

使用

$ cd ~/go/bin
$ timescaledb-parallel-copy --help

foo.csv 生产一个 sample 表格式的csv文件。

single-threaded

$ timescaledb-parallel-copy --db-name test --table sample --file foo.csv

2 workers

$ timescaledb-parallel-copy --db-name test --table sample --file foo.csv --workers 2

2 workers, report progress every 30s

$ timescaledb-parallel-copy --db-name test --table sample --file foo.csv --workers 2 --reporting-period 30s

Treat literal string ‘NULL’ as NULLs:

$ timescaledb-parallel-copy --db-name test --table sample --file foo.csv --copy-options "NULL 'NULL' CSV"

参考:
https://github.com/timescale/timescaledb-parallel-copy
https://docs.timescale.com/latest/using-timescaledb/tooling

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据库人生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值