Does SQL Server support parallel bulk inserts into the same database table?
Some clarifications for my particular use case:
- The table has a clustered index composed of two distinct index keys, and two non-clustered indexes, each one consisting of a single index key.
- Parallel here means from multiple, distinct connections. Each connection is a unique sqlalchemy.orm.session object, and each Session is inserting 20k records of data at the same time using the
Session.bulk_insert_mappings()
method.
The specific questions I have:
- I am trying to understand what is happening under the hood on the SQL Server side. Is there a queue for all of the bulk inserts, and each bulk insert is executed one by one, in the order the came in? Or are all the inserts performed at the same time, in parallel?
- We are also assuming that no two distinct connections will be attempting to insert the same records (based on Primary Key), BUT what if two of the parallel connections WERE trying to insert records that would cause a PK violation?
- Are the answers to the questions above different if we are asking for SQL Server 2008 vs 2017?
- Does Microsoft have any sort of documentation on this?