Solved

Can I drop indexes during large (60 million row) SQL 2005 Insert!

Posted on 2007-11-21
13
343 Views
Last Modified: 2008-02-01
I am doing an insert from one server to another...the source table is 60 million records, and it is taking forever....I need to drop the indexes (there are 10 of them) on the destination table, but am only about 19 million records through the insert.  Is this possible - i.e. can I open a separate session in SQL Management Studio and drop the indexes?
0
Comment
Question by:p_love
  • 4
  • 2
  • 2
  • +3
13 Comments
 
LVL 16

Accepted Solution

by:
SQL_SERVER_DBA earned 400 total points
ID: 20329194
You should be fine
0
 
LVL 1

Author Comment

by:p_love
ID: 20329202
Thanks...

will it help?!
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 100 total points
ID: 20329276
Hello p_love,
>can I open a separate session in SQL Management Studio and drop the indexes?

I am really not sure abt this, but i recommend you stop the copying opn , drop the index and then start copying.



Aneesh R
0
 
LVL 1

Author Comment

by:p_love
ID: 20329313
Hi,

Having waited 8 hours...I am reluctant to start again.  I have a finite window to do this in.  I did a test run on Sunday and it took only 4 hours.  I have a job starting in 8 hours which will be fairly dependent on this data being present.
0
 
LVL 16

Expert Comment

by:SQL_SERVER_DBA
ID: 20329316
I don't think it will help
0
 
LVL 69

Expert Comment

by:ScottPletcher
ID: 20329505
Is the data coming from an existing table or from a file(s)?

If file(s), you should use BULK INSERT, as that is the fastest method for loading large volumes of data.

Dropping indexes would certainly help prior to the load starting.  Not sure if it will work now.  You could try running a test and if that doesn't cause problems, try it live.

Also, if there any trigger(s) on the table, disabling them, if possible, would also speed the load.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 7

Expert Comment

by:wittyslogan
ID: 20330268
does dts load data faster?
0
 
LVL 69

Expert Comment

by:ScottPletcher
ID: 20330477
No; BULK INSERT is much faster than DTS.
0
 
LVL 7

Expert Comment

by:wittyslogan
ID: 20331173
IS the server to server thing the problem?
If it is can't you just backup and restore the database over to the target server and then do the bulk insert on the same server?
0
 
LVL 1

Author Comment

by:p_love
ID: 20331771
Hi,

One server is in Sweden and the other is in the US.  I am using OpenQuery.  It took 4 hours on a test run on Sunday, but 9 hours today.  I have cancelled and will investigate further.  I may do a RAW export via SSIS, then do a RAW import.

Thanks

0
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 20336608
<<I am doing an insert from one server to another...the source table is 60 million records, and it is taking forever....I need to drop the indexes (there are 10 of them) on the destination table, but am only about 19 million records through the insert.  Is this possible>>
Use BULK INSERT...and make sure you have no network bottlenecks...

Hope this helps...
0
 
LVL 1

Author Comment

by:p_love
ID: 20338761
Use BULK INSERT...and make sure you have no network bottlenecks...

Hi,

I appreciate this.  The question however wasnt, how could I do this better, it was - can I drop the indexes "during" a large insert.   My only worry with bulk insert is I have to do a bulk export first and didnt fancy it on 60 million records...
0
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 20339314
<<can I drop the indexes "during" a large insert.>>
Yes.  But it is a tedious process to drop  them (you must drop constraints too) and recreate them:  you will have to do lots of scripting for this  Indexes are *not* the primary reason for which your inserts takes forever...Replacing *inserts* by *bulk inserts* is easy to do and you don't have to worry about indexes.

Hope this helps...
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now