Skip to content

Commit

Permalink
Avoid duplicate data in benchmark.db
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmakait committed Aug 7, 2024
1 parent a8a31b1 commit fe66d43
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions ci/scripts/combine-dbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@ set -euxo pipefail

DB_NAME=${DB_NAME:-'benchmark.db'}

# Possibly apply migrations to the main db,
# working on a copy with a known name so it's
# easier to refer to in sqlite
if [ -f "$DB_NAME" ]; then
cp "$DB_NAME" benchmark.tmp.db
else
sqlite3 benchmark.tmp.db "VACUUM;"
fi
DB_NAME=benchmark.tmp.db alembic upgrade head
alembic upgrade head

# Delete old records and vacuum to reduce on-disk size
sqlite3 benchmark.tmp.db <<EOF
sqlite3 "$DB_NAME" <<EOF
DELETE FROM test_run WHERE session_id not in (SELECT DISTINCT session_id FROM test_run WHERE start > date('now', '-90 days'));
VACUUM;
EOF
Expand All @@ -34,7 +26,7 @@ do
for tab in "tpch_run" "test_run"
do
sqlite3 "$FILE" <<EOF
attach "benchmark.tmp.db" as lead;
attach "$DB_NAME" as lead;
create temporary table tmp as select * from main.$tab;
update tmp set id=NULL;
insert into lead.$tab select * from tmp;
Expand All @@ -43,4 +35,4 @@ EOF
done
done

mv benchmark.tmp.db "$DB_NAME"
sqlite3 "$DB_NAME" "VACUUM;"

0 comments on commit fe66d43

Please sign in to comment.