Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert Into From Select Performance SQL Server

I created a query in which I insert to a empty table the result of a select from other table.

This select itself takes ~20 minutes (30 M Rows, 120 Columns and "Where" conditions, and it's fine), but the insert into takes ~1 hour.

Do you have any suggestions of how to improve it?

What I've done is as in the below example.

Insert Into tableA
Select *
From TableB

Appreciate your help!

like image 637
Ric_R Avatar asked Oct 17 '22 20:10

Ric_R


1 Answers

Drop all the indexes on TableA , then insert again :

INSERT INTO tableA
SELECT * FROM TableB

Indexes are known to slow down insert statements .

like image 67
sagi Avatar answered Oct 20 '22 22:10

sagi