[sql]: Optimize conditions - #6129
Conversation
Change while loop to a for loop, cache type[entityKind] access, and add `isAnyKindIn(value, entityKinds)` method to only tranverse the prototype once when checking for entity kind
- Optimize `bindIfParam()` to use `isAnyKindIn()` to only tranverse the prototype chain once - Cache separator chunks and open/close parenthesis chunks - Allocate 1 SQL object with all the joined chunks instead of 2, which also speeds up `toSQL()` on the result object
Use cached string chunks directly instead of using `sql` template
|
let's maybe since we already have cc: @Sukairo-02 @aquapi |
|
also for we can also expore benchmark solutions to count eventloop iterations per solution, didn't have time to explore that domain |
|
also I still think we shall do these kind of optimisations in a reverse order, aka we rebuild query builder path as a separate entry point gradually adding features for example we start with |
…, `notInArray()` building performance Manually construct the chunk array instead of using `sql` tagged template
I think we can implement a node addon that calls libuv to get this. |
|
@aquapi that would be awesome, I primarily care about node+bun, if it will be compatible, if node only - still fine |
|
@AlexBlokh oh wait there is a package: https://npmx.dev/event-loop-stats |
Current progress:
is()calls to multipleinstanceofchecks and one prototype tranversal.and()andor()by caching common string chunks and directly join the chunks instead of usingsqltemplate orsql.join().