?
Solved

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

Posted on 2007-11-21
13
Medium Priority
?
354 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +3
13 Comments
 
LVL 16

Accepted Solution

by:
SQL_SERVER_DBA earned 1200 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 300 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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:Scott Pletcher
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
 
LVL 7

Expert Comment

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

Expert Comment

by:Scott Pletcher
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
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.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

770 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