K
Kysely5mo ago
tzezar

transaction takes too long

I have a problem with transactions. What might be the reason that db.transaction() adds more than 10ms latency?
Query took 2.3298759999997856
Validation took 0.006788000000597094
Update took 0.6013680000005479
Refresh took 0.9085340000001452
Transaction took 13.280770999999731
Query took 2.3298759999997856
Validation took 0.006788000000597094
Update took 0.6013680000005479
Refresh took 0.9085340000001452
Transaction took 13.280770999999731
"kysely": "^0.27.3",
"pg": "^8.11.5",
"kysely": "^0.27.3",
"pg": "^8.11.5",
+ postgresql Below I will attach code that generated those results. Transaction overhead is present in every function call. What might be the reason for the more than 10ms spent on a transaction?
3 Replies
tzezar
tzezar5mo ago
No description
tzezar
tzezar5mo ago
connection:
import { DB } from './kysely-types';
import { Pool } from 'pg'
import { CamelCasePlugin, Kysely, PostgresDialect, Transaction } from 'kysely'

const dialect = new PostgresDialect({
pool: new Pool({
connectionString: "",
max: 10
})
})
export const db = new Kysely<DB>({
dialect,
plugins: [
new CamelCasePlugin()
],
log(event) {
// console.log(event.query.sql)
}
})

export type Connection = Kysely<DB> | Transaction<DB>
import { DB } from './kysely-types';
import { Pool } from 'pg'
import { CamelCasePlugin, Kysely, PostgresDialect, Transaction } from 'kysely'

const dialect = new PostgresDialect({
pool: new Pool({
connectionString: "",
max: 10
})
})
export const db = new Kysely<DB>({
dialect,
plugins: [
new CamelCasePlugin()
],
log(event) {
// console.log(event.query.sql)
}
})

export type Connection = Kysely<DB> | Transaction<DB>
koskimas
koskimas5mo ago
Don't know, but it's not caused by Kysely. Kysely does nothing but run begin and commit/rollback If it reserves a new connection (no free cached connections in the pool) it takes a while. Do you get the same result of you make sure there are connections in the pool?
Want results from more Discord servers?
Add your server