Skip to content

Speed up SelectQueryBuilder.if type checking - #1965

Open
koskimas wants to merge 1 commit into
remove-recursive-type-checks-from-kysely-classfrom
speed-up-if-function-type-check
Open

Speed up SelectQueryBuilder.if type checking#1965
koskimas wants to merge 1 commit into
remove-recursive-type-checks-from-kysely-classfrom
speed-up-if-function-type-check

Conversation

@koskimas

@koskimas koskimas commented Aug 1, 2026

Copy link
Copy Markdown
Member

Significantly speed up SelectQueryBuilder.if type checking.

It had kinda stupid types, that required a full SelectQueryBuilder comparison for each $if.

This PR also adds type benchmarks for various commonly used kysely queries.

This is on top of #1962.

@pkg-pr-new

pkg-pr-new Bot commented Aug 1, 2026

Copy link
Copy Markdown

commit: 799752f

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

⏱️ TypeScript Benchmark Results

✅ ⏱️  No benchmark changes detected.

@igalklebanov igalklebanov added the typescript Related to Typescript label Aug 1, 2026
Comment on lines +99 to +117
bench('kysely.updateTable(table).set(row)', () => {
return kysely.updateTable('my_table').set(row)
}).types([848, 'instantiations'])

bench('kysely.updateTable(table).set(column, value)', () => {
return kysely
.updateTable('my_table')
.set('my_table.col_2e66a5c7e24d1d066230f368ce8b094e', 'x')
}).types([3078, 'instantiations'])

bench('kysely.updateTable(table).set(eb => row)', () => {
return kysely.updateTable('my_table').set((eb) => ({
col_1d726898491fbca9a8dac855d2be1be8: eb(
'col_1d726898491fbca9a8dac855d2be1be8',
'+',
1,
),
}))
}).types([3520, 'instantiations'])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these don't belong in this bench.

Comment on lines +123 to +125
bench('kyselyAny.updateTable(table).set(row)', () => {
return kyselyAny.updateTable('my_table').set(row)
}).types([333, 'instantiations'])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't belong in this bench.


console.log('if.bench.ts:\n')

bench.baseline(() => {})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's probably better to:

Suggested change
bench.baseline(() => {})
bench.baseline(() => {
return kysely.selectFrom('my_table').select('my_table.id')
})

@igalklebanov igalklebanov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey 👋

Nice! 💪

How big of a -% change in insantiations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typescript Related to Typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants