Closed SebastianSzturo closed 2 years ago
Here are the results running the query with Exqlite directly:
{:ok, conn} = Exqlite.Sqlite3.open("./dev.db")
:ok =
Exqlite.Sqlite3.execute(
conn,
"SELECT transaction_date, transaction_amount FROM transactions"
)
Benchmarking exqlite_query ...
Name ips average deviation median 99th %
exqlite_query 11.36 88.02 ms ±0.82% 88.12 ms 89.67 ms
Looks like the issue happens when using Exqlite.Connection
:
{:ok, db} =
DBConnection.start_link(Exqlite.Connection,
database: "./dev.db",
journal_mode: :wal,
timeout: 25_000
)
{:ok, _, result} =
DBConnection.execute(
db,
%Exqlite.Query{
statement: "SELECT transaction_date, transaction_amount FROM transactions"
},
[]
)
I'll open an issue in https://github.com/elixir-sqlite/exqlite
For reference: https://github.com/elixir-sqlite/exqlite/issues/199
Thanks, will take a look into this.
I've noticed that large queries are significantly slower via
ecto_sqlite3
than through thesqlite3
CLI.Example:
Here is the example data of ~650k rows: dev.db.zip
Via Ecto: 22504.3ms
Via Ecto (Raw SQL): 21520.2ms
Via SQLite3 CLI or any other SQLite3 GUI:
Is there any good explanation for this performance difference or some obvious steps to improve the performance?