From ef1c97c0025146d92ba53b2c63675e5f9d230c97 Mon Sep 17 00:00:00 2001 From: Alex Garcia Date: Sun, 12 Dec 2021 16:51:05 -0800 Subject: [PATCH 1/2] Add pre SQLite approach, with generate_series --- bench.sh | 8 ++++++++ load.sql | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 load.sql diff --git a/bench.sh b/bench.sh index fa12f10..6a67df8 100755 --- a/bench.sh +++ b/bench.sh @@ -2,6 +2,14 @@ # runs each of the scripts one after another, prints the measurements to stdout export TZ=":Asia/Kolkata" +# benching sqlite cli +rm -rf sqlite3.db +echo "$(date)" "[SQLite] running sqlite3 (100_000_000) inserts" +time sqlite3 sqlite3.db '.read schema.sql' '.read load.sql' +if [[ $(sqlite3 sqlite3.db "select count(*) from user";) != 100000000 ]]; then + echo "data verification failed" +fi + # benching naive version rm -rf naive.db naive.db-shm naive.db-wal echo "$(date)" "[PYTHON] running naive.py (10_000_000) inserts" diff --git a/load.sql b/load.sql new file mode 100644 index 0000000..5c04623 --- /dev/null +++ b/load.sql @@ -0,0 +1,13 @@ +create table IF NOT EXISTS user ( + id INTEGER not null primary key, + area CHAR(6), + age INTEGER not null, + active INTEGER not null +); + +insert into user (area, age, active) +select + abs(random() % 99999) as area, + (abs(random() % 3) + 1) * 5 as age, + abs(random() % 1) as active +from generate_series(1, 100000000); From 0d8ab0eb117ad78d9d11f9f45ffb4da2505ba2a7 Mon Sep 17 00:00:00 2001 From: Alex Garcia Date: Sun, 12 Dec 2021 17:28:29 -0800 Subject: [PATCH 2/2] rm unneeded schema.sql --- bench.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench.sh b/bench.sh index 6a67df8..4363b7c 100755 --- a/bench.sh +++ b/bench.sh @@ -5,7 +5,7 @@ export TZ=":Asia/Kolkata" # benching sqlite cli rm -rf sqlite3.db echo "$(date)" "[SQLite] running sqlite3 (100_000_000) inserts" -time sqlite3 sqlite3.db '.read schema.sql' '.read load.sql' +time sqlite3 sqlite3.db '.read load.sql' if [[ $(sqlite3 sqlite3.db "select count(*) from user";) != 100000000 ]]; then echo "data verification failed" fi