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
Solved

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

Posted on 2007-11-21
13
350 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

791 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