liveBook · Manning

Bulk insertion

As explained in 100 SQL Server Mistakes and How to Avoid Them

A bulk insert operation loads a large volume of rows into a database in an optimized manner.

Bulk insertion loads many rows efficiently, but treating it like an ordinary INSERT can create unnecessary I/O, transaction-log work, page splits, and delays. section 11.9 section 6.2

Avoid these two mistakes:

  • 1. Leaving nonclustered indexes active. Each inserted row must update the table and every affected index, increasing I/O, page splits, fragmentation, and transaction-log writes. Disable only the nonclustered indexes, then rebuild them after loading; disabling the clustered index makes the table inaccessible. section 11.9
  • 2. Accepting default data-load settings. In SSIS, tune DefaultBufferMaxRows and DefaultBufferSize, and enable OLE DB fast-load options. Test buffer and batch sizes instead of assuming larger is always faster. section 6.2

Nightly advertising-data load

A nightly pipeline loads impressions, clicks, and events from multiple files. With hundreds of millions of impressions and a fixed morning deadline, load optimization determines whether processing finishes in time. A safer SQL Server pattern disables nonclustered indexes on ImpressionsArchive, inserts from the source table, and rebuilds the indexes afterward. section 11.9 section 6.2

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Explains index and buffer trade-offs with operational examples and executable T-SQL, without developing a general bulk-loading theory.
Examples
Uses ImpressionsArchive, advertising ETL files, buffer-size tests, and a disable-insert-rebuild script.
What you can do after
Operate/configure bulk loads by disabling appropriate indexes, rebuilding them afterward, and tuning SSIS buffer and fast-load settings.
How it connects
Connects bulk insertion to nonclustered indexes, page splits, transaction logs, SSIS data flows, buffers, batch sizes, and OLE DB destinations.

Also explained in

Compare how 2 books explain bulk insertion →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.