Asynchronous or parallel execution of database commands will not speed up bad database code, but can hurt performance. 100 entries is a very small number, which means that something strange is happening in the database access code. This will not be fixed if you execute multiple statements in parallel.
Firstly, in order for operations to be performed in parallel, a separate connection is required for each operation, which leads to more locks, more locks, and longer time spent on the wire.
Secondly, much more time is spent on establishing connections and transferring data via cable than it did on actual INSERT or UPDATE . Even if you execute one write statement, you should not have performance issues. If you do this, it's probably because saveToDb doing something weird, or you don't have the appropriate indexes, or the statement really works very poorly.
Finally, the best way to increase database insertions is to use bulk operations, such as SQL Server BULK INSERT , to insert a large number of records at a time or SqlBulkCopy . These operations are optimized to handle a large number of records (many thousands).
In any case, it pays much more to fix the statements and access code for the database than to perform parallel operations.
source share