ClickHouse/benchmark/compatible/timescaledb/benchmark.sh

35 lines
1.4 KiB
Bash
Raw Normal View History

2022-06-26 04:00:07 +00:00
#!/bin/bash
# Install
sudo apt-get update
sudo apt install gnupg postgresql-common apt-transport-https lsb-release wget
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo bash -c 'echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main" > /etc/apt/sources.list.d/timescaledb.list'
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo apt-key add -
sudo apt-get update
sudo apt install timescaledb-2-postgresql-14
2022-06-26 05:31:49 +00:00
sudo bash -c "echo \"shared_preload_libraries = 'timescaledb'\" >> /etc/postgresql/14/main/postgresql.conf"
2022-06-26 04:00:07 +00:00
sudo systemctl restart postgresql
2022-06-26 05:31:49 +00:00
sudo -u postgres psql -c "CREATE DATABASE test"
sudo -u postgres psql test -c "CREATE EXTENSION IF NOT EXISTS timescaledb"
2022-06-26 05:59:40 +00:00
# Import the data
wget 'https://datasets.clickhouse.com/hits_compatible/hits.tsv.gz'
gzip -d hits.tsv.gz
chmod 777 ~ hits.tsv
2022-06-26 05:31:49 +00:00
sudo -u postgres psql test < create.sql
sudo -u postgres psql test -c "SELECT create_hypertable('hits', 'eventtime')"
sudo -u postgres psql test -c "CREATE INDEX ix_counterid ON hits (counterid)"
sudo -u postgres psql test -c "ALTER TABLE hits SET (timescaledb.compress, timescaledb.compress_orderby = 'counterid, eventdate, userid, eventtime')"
sudo -u postgres psql test -c "SELECT add_compression_policy('hits', INTERVAL '1s')"
sudo -u postgres psql test -t -c '\timing' -c "\\copy hits FROM 'hits.tsv'"
2022-06-26 05:59:40 +00:00
# 1619875.288 seconds (26:59.875)
./run.sh 2>&1 | tee log.txt