Scripts for benchmarking partitioning

main
Max Ignatenko 2024-02-23 11:10:23 +00:00
parent 78a17bf238
commit 297e9e0347
5 changed files with 48 additions and 1 deletions

1
.gitignore vendored
View File

@ -2,4 +2,5 @@ go.work*
.env
*.csv
*.out
*.log
csv_export.tgz

1
benchmark/.env 120000
View File

@ -0,0 +1 @@
../.env

View File

@ -0,0 +1,6 @@
#!/bin/sh
cd ..
docker compose exec -i postgres pg_dump -U postgres -d bluesky -t records -t records_id_seq --schema-only | sed -E -e 's/PARTITION BY.*/;/' > records.sql
docker compose exec -i postgres pg_dump -U postgres -d bluesky --table-and-children records --load-via-partition-root --data-only | lz4 > records.sql.lz4

View File

@ -0,0 +1,14 @@
version: '3.8'
services:
postgres:
image: "postgres:16"
volumes:
- "${DATA_DIR:?specify data dir in .env file}/benchmark:/var/lib/postgresql/data:rw"
restart: always
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
POSTGRES_DB: bluesky
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:?specify password in .env file}"
command: ["-c", "max_connections=1000"]

25
benchmark/run.sh 100755
View File

@ -0,0 +1,25 @@
#!/bin/sh
output="psql_$(date '+%y%m%d_%H%M%S').log"
set -x
docker compose stop postgres
. ./.env
sudo rm -rf ${DATA_DIR:?DATA_DIR not set}/benchmark
echo "$(date): Starting data import..."
docker compose up -d postgres
while ! docker compose exec postgres psql -U postgres -d bluesky -c 'select 1;'; do sleep 1; done
cat ../records.sql | docker compose exec -iT postgres psql -U postgres -d bluesky
lz4cat ../records.sql.lz4 | docker compose exec -iT postgres psql -U postgres -d bluesky
echo "$(date): Data import done"
cat ../db-migration/20240217_partition.sql \
| docker compose exec -iT postgres psql -U postgres -d bluesky --echo-queries -c '\timing' \
| tee -a "${output}"