Skip to content

Commit

Permalink
Fix script and results
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayank-Baranwal committed Dec 7, 2023
1 parent 59bd98e commit 7ba320c
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 25 deletions.
2 changes: 1 addition & 1 deletion queries/q7.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- List top 10 countries with the most classical music artists (born or started before 1850) along
-- List top countries with the most classical music artists (born or started before 1850) along
-- with the number of associated artists.

explain analyze select
Expand Down
3 changes: 0 additions & 3 deletions queries/q9.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ EXPLAIN ANALYZE select * from artist where length(name) < 24 and id < 2000000;
-- fpd_ff: 0.0215s
-- fpd_ff_sb_0.3: 0.0214s


0.0165s
0.0177s
10 changes: 10 additions & 0 deletions results/res_fpd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
q1.sql,0.015068,0.016345,0.01589776923076923,0.016111
q10.sql,0.019811,0.02137,0.020657153846153846,0.020716
q2.sql,0.016159,0.017269,0.016622076923076927,0.016569
q3.sql,0.036405,0.038234,0.03710853846153846,0.03705
q4.sql,0.011746,0.012201,0.012039999999999999,0.012082
q5.sql,0.14229,0.162057,0.15040492307692307,0.149613
q6.sql,0.030659,0.035977,0.03292892307692307,0.032533
q7.sql,0.013865,0.017567,0.015574307692307693,0.016042
q8.sql,0.085457,0.108914,0.09386123076923078,0.091009
q9.sql,0.018735,0.019358,0.01906684615384615,0.019098
10 changes: 10 additions & 0 deletions results/res_fpd_ff.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
q1.sql,0.004263,0.005503,0.004847461538461538,0.004853
q10.sql,0.019191,0.020792,0.01999253846153846,0.020017
q2.sql,0.012899,0.014673,0.01377276923076923,0.013799
q3.sql,0.031693,0.03432,0.03277884615384616,0.032862
q4.sql,0.012352,0.013049,0.012710538461538464,0.012723
q5.sql,0.046711,0.050172,0.048659076923076916,0.049121
q6.sql,0.018129,0.021761,0.019365307692307692,0.019199
q7.sql,0.013754,0.017121,0.01525630769230769,0.015357
q8.sql,0.081516,0.105969,0.09175184615384614,0.089223
q9.sql,0.019624,0.021739,0.020462692307692307,0.020156
10 changes: 10 additions & 0 deletions results/res_fpd_sff.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
q1.sql,0.00419,0.00556,0.004845769230769231,0.004879
q10.sql,0.019297,0.021021,0.020138846153846153,0.020018
q2.sql,0.016373,0.017211,0.016763615384615384,0.016792
q3.sql,0.032216,0.033723,0.032866,0.032944
q4.sql,0.011847,0.012255,0.012025846153846153,0.011983
q5.sql,0.047816,0.050562,0.04929253846153846,0.049287
q6.sql,0.018529,0.024122,0.020033230769230765,0.018941
q7.sql,0.013691,0.019411,0.015571846153846155,0.015596
q8.sql,0.088375,0.105805,0.09507761538461537,0.093675
q9.sql,0.0188,0.020019,0.019406769230769227,0.019427
10 changes: 10 additions & 0 deletions results/res_none.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
q1.sql,0.015333,0.016466,0.015758076923076923,0.01572
q10.sql,0.019951,0.021624,0.02080853846153846,0.020848
q2.sql,0.015844,0.017063,0.016454615384615384,0.016497
q3.sql,0.134473,0.148503,0.1411465384615385,0.140785
q4.sql,0.01178,0.012262,0.012023692307692308,0.01206
q5.sql,0.514083,0.623423,0.5551010000000001,0.55046
q6.sql,0.038386,0.050999,0.04415169230769231,0.043339
q7.sql,0.014166,0.017644,0.015391692307692304,0.014847
q8.sql,0.587889,0.845098,0.6632696153846154,0.628471
q9.sql,0.01895,0.021157,0.01953423076923077,0.019357
45 changes: 24 additions & 21 deletions run_sql_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,39 @@

duckdb_file = "db_small.duckdb"
duckdb_query_path = "queries"
result_file = "results/res.txt"


RUN_COUNT = 13
WARMUP_COUNT = 2

for query_file in os.listdir(duckdb_query_path):
print("Running {}", query_file)
with open(result_file, "w") as res_file:

con = duckdb.connect(duckdb_file)
duckdb_query = os.path.join(duckdb_query_path, query_file)
with open(duckdb_query, "r") as sql_file:
sql_query = sql_file.read()
for query_file in sorted(os.listdir(duckdb_query_path)):
con = duckdb.connect(duckdb_file)
duckdb_query = os.path.join(duckdb_query_path, query_file)
with open(duckdb_query, "r") as sql_file:
sql_query = sql_file.read()

con.sql("PRAGMA enable_profiling='json'")
# Run the query a few times to warm up memory
con.sql("PRAGMA enable_profiling='json'")
# Run the query a few times to warm up memory

print("Warmup: {}", sql_query)
for _ in range(WARMUP_COUNT):
con.sql(sql_query)
# print("Warmup")
for _ in range(WARMUP_COUNT):
con.sql(sql_query)

times = []
times = []

print("Running test: {}", sql_query)
for i in range(RUN_COUNT):
output = con.sql(sql_query).to_df()
res_str = output['explain_value'][0]
res_dict = json.loads(res_str)
times += [float(res_dict["timing"])]
# print("Running test")
for i in range(RUN_COUNT):
output = con.sql(sql_query).to_df()
res_str = output['explain_value'][0]
res_dict = json.loads(res_str)
times += [float(res_dict["timing"])]

times = sorted(times)
print("Query file: {}, min_time: {}, max_time: {}, avg_time: {}, median_time: {}", query_file, times[0], times[-1], sum(times)/RUN_COUNT, times[RUN_COUNT/2])
con.close()
times = sorted(times)
print("Query file: {}, min_time: {}, max_time: {}, avg_time: {}, median_time: {}".format(query_file, times[0], times[-1], sum(times)/RUN_COUNT, times[int(RUN_COUNT/2)]))
res_file.write("{},{},{},{},{}\n".format(query_file, times[0], times[-1], sum(times)/RUN_COUNT, times[int(RUN_COUNT/2)]))
con.close()

# print(res['explain_value'][0])

0 comments on commit 7ba320c

Please sign in to comment.