Skip to content

Commit

Permalink
Added q4 + script
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayank-Baranwal committed Dec 7, 2023
1 parent 703dfdb commit aab179e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions queries/q4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
explain analyze select * from work where id%5 = 1;

22 changes: 22 additions & 0 deletions run_sql_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import duckdb
import json

duckdb_file = "db.duckdb"
duckdb_query = "queries/q1.sql"

con = duckdb.connect(duckdb_file)
with open(duckdb_query, "r") as sql_file:
sql_query = sql_file.read()

con.sql("PRAGMA enable_profiling='json'")
# print(sql_query)
res = con.sql(sql_query).to_df()
print(res['explain_value'][0])
res = (res['explain_value'][0])

res = json.loads(res)
total_time = res["timing"]
# seq_time = res["children"]
print(f"Total Time: {total_time}")

con.close()

0 comments on commit aab179e

Please sign in to comment.