Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server insert slow

I have two servers where I installed SQL Server 2008

  • Production: RAID 1 on SCSI disks
  • Test: IDE disk

When I try to execute a script with about 35.000 inserts, on the test server I need 30 sec and instead on the production server more than 2 min! Does anybody know why such difference? I mean, the DB are configured in the same way and the production server has also a RAID config, a better processor and memory...

THANKS!

like image 475
andrew0007 Avatar asked Mar 15 '10 12:03

andrew0007


1 Answers

Be aware that RAID 1 is for redundancy, and speed varies depending on the scenario. 35k inserts could cause a heavy random write overhead, slowing down performance.

How are you inserting these rows, are they wrapped in a SQL Transaction? If not already, then know that transactions cache queries and does batch disk updates, greatly increasing speed.

If it's via a SQL script file, wrap the inserts in BEGIN TRANSACTION / END TRANSACTION. For so many records importing from file is probably better.

like image 191
invert Avatar answered Sep 20 '22 11:09

invert