IN query performance
buildIn
uses lodash.reduce
to merge the elements of an IN clause into the existing params. When the number of values is large the operation becomes very slow. From my tests with 20'000 values:
lodash.reduce: 750ms
Array.reduce: 300ms
optimized code (this PR): 10ms
The code is less readable after my changes but I think the perf warrants it. For reference total operation time including fetching is ~1300ms before, ~600ms after.