fix: Make bulkCreate run in O(N) time. Fixes issue #4247. (#7391)
In generating the bulk insert query, the serials are stored in an array. This array can potentially be up to size N, which is the number of rows to be created. When generating the tuples at a later stage, we walk through the records one-by-one - O(N) iterations. However, in a single iteration, we were performing a lookup in the serials array (indexOf costs O(N)), leading to a O(N^2) runtime and poor performance for large number of records inserted. This patch converts the serials array into an object map instead, so lookups cost O(1) time.
Showing
with
4 additions
and
3 deletions
-
Please register or sign in to post a comment