Reputation: 191
Is there any way to optimize simple INSERT queries like the following?
INSERT master_table
SELECT * FROM increment
The execution plan is Table Scan
(13%) -> Table Insert
(87%)
What can I do to make it execute faster?
Upvotes: 1
Views: 782
Reputation: 32614
You leave little choice to scan the entire table as you want all the data, however a couple of things you can do.
master_table
insert into master_table with(tablock)...
This will make the inserts into the target table as fast as possible and untilise parallel execution for reading the table to do the insert, a feature that was added in 2016.
Upvotes: 1