How does BULK INSERT work internally?

后端 未结 3 1896
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 13:48

Could someone please explain how does BULK INSERT internally work and why is it much faster than the normal INSERT operations ?

Regards, Shishir.

3条回答
  •  清酒与你
    2020-12-31 14:13

    At the very least it can avoid the overhead of creating and commiting a transaction for each record to be inserted. There are other savings to be had: for example shipping larger chunks of data across the network rather than one record at a time will help.

    Then, perhaps more interestingly, the DB implementor can (I don't know if any specific vendor actually does this) start getting clever - they can look at the set of records to be inserted and rather than reorganising pages of data to accommodate single records can make bulk reorganisations of the pages to allow for new insertions, likewise we can imagine that shuffling indices could be done more efficiently if we know that we are inserting a set of records.

提交回复
热议问题