waterchiller
waterchiller
DTDrizzle Team
Created by waterchiller on 4/10/2024 in #help
Huge Performance difference between select and query
I was wondering if there should really be a more than 250x performance difference between the same query using select with leftJoin and query
const rows = await db
.select()
.from(transactions)
.leftJoin(
events,
eq(events.transactionHash, transactions.transactionHash),
)
.where(eq(transactions.contract, contract));
const rows = await db
.select()
.from(transactions)
.leftJoin(
events,
eq(events.transactionHash, transactions.transactionHash),
)
.where(eq(transactions.contract, contract));
and
const txn = await db.query.transactions.findMany({
where: (t) => eq(t.contract, contract),
with: { events: true },
});
const txn = await db.query.transactions.findMany({
where: (t) => eq(t.contract, contract),
with: { events: true },
});
for the query we get duration: 41788.126207999994 ms, amount: 5278 and for the select + left join duration: 144.189916000003ms, amount: 5278 So the same query returns the same results but one is so much slower. Am I missing something or is this expected?
5 replies