Allow bulk usage of sequence while using `DbContext.Set<T>.AddRange(Async)`
See original GitHub issueLately, I was trying to insert bulk records on multiple tables those inserts were just one-time inserts and I didn’t want to stress myself out. So I tried to do it in a casual way: Create a list of entities add them via AddRangeAsync
and save the changes. While doing this I realized this process taking a fairly long time. And enabled detailed logs and it was the flooding of select nextval
queries. So it was literally 1 nexval query per entity added indeed. And %90 of the time spent was getting these sequence numbers from the DB. It should be done in one round trip to get the required number of sequences while doing these inserts. Postgresql allows us to write queries like this: select nextval('my_seq') from generate_series(1,3);
so in theory we can get them in a bulk way. So I hope it is doable in a provider level and it’s not a limitation of EF itself.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
It would have been awesome configuration if did
r.StartsAt(1).IncrementsBy(1000)
@roji your quick answer is much appreciated. Sorry for taking your time for this kind of silly misconception.