School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,221 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,693 people online right now. Registration is fast and FREE... Join Now!




Inserting 25 millions records SQL server takes 3hrs.

 

Inserting 25 millions records SQL server takes 3hrs.

foxon177

15 May, 2008 - 10:03 PM
Post #1

New D.I.C Head
*

Joined: 7 May, 2008
Posts: 3



Thanked: 2 times
My Contributions
Inserting 25 millions records SQL server takes 3hrs.


I am using SQL Server Standard Edition .

in one of my table , there i am inserting around 25 millions records and that takes time around more than 3 hrs.

same thing is happening while fetching records from that table.

this database contains only single file group i.e primary

and that table contains .. Clustered as well as non clustered index.

it doesnot have any Triggers.

How do i increase this performance.

Paritioning of table cannot be use in SQL Server Standard Edition.

Or Dropping all non clustered index before insert operation will improve my performance.

Please suggest me.

Thanks

Msdes
Fexon
Asia

User is offlineProfile CardPM
+Quote Post


RodgerB

RE: Inserting 25 Millions Records SQL Server Takes 3hrs.

15 May, 2008 - 10:05 PM
Post #2

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,238



Thanked: 33 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
I suggest you read the forum rules and post in the appropriate section.
User is offlineProfile CardPM
+Quote Post

KYA

RE: Inserting 25 Millions Records SQL Server Takes 3hrs.

15 May, 2008 - 10:05 PM
Post #3

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 11,502



Thanked: 508 times
Dream Kudos: 2875
Expert In: C, C++, Java

My Contributions
Wrong forum

Try Databases

\0/ rodger

This post has been edited by KYA: 15 May, 2008 - 10:06 PM
User is offlineProfile CardPM
+Quote Post

thor78

RE: Inserting 25 Millions Records SQL Server Takes 3hrs.

15 May, 2008 - 11:08 PM
Post #4

D.I.C Head
Group Icon

Joined: 6 May, 2008
Posts: 121



Thanked: 1 times
Dream Kudos: 50
My Contributions
That long huh? biggrin.gif

Move to database forum?
User is offlineProfile CardPM
+Quote Post

Amadeus

RE: Inserting 25 Millions Records SQL Server Takes 3hrs.

16 May, 2008 - 04:34 AM
Post #5

g+ + -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 13,284



Thanked: 149 times
Dream Kudos: 25
My Contributions
I will move this, but I'd also suggest you consider a few things:

1. If you are inserting 25 million records, you should be doing these in batches. If you stagger them out into smaller batches, your runtime will decrease.
2. If you are fetching 25 million records at the same time, you may need to look at a shift in process, or at least implementing a secondary table that contains summary information (which is the only reason I can think of someone needing 25 million records in a single fetch.
3. Index the data.
4. A final option is to perhaps consider switching to an Oracle DB server.

Is your DB server dedicated?
User is offlineProfile CardPM
+Quote Post

Trogdor

RE: Inserting 25 Millions Records SQL Server Takes 3hrs.

20 May, 2008 - 03:38 AM
Post #6

D.I.C Addict
Group Icon

Joined: 6 Oct, 2006
Posts: 619



Thanked: 15 times
Dream Kudos: 200
My Contributions
1: dont use any index while inserting. You can drop the index (all indexes, triggers, and all foreign key constraints too) before, and recreate it after the bulk insert. This will be a lot faster.
2: use a special tool to insert the data.

but any way you look at it, 25 mil records is a lot of data, it will take a while.

Other ways to increase performance have nothing to do with the database itself but with tuning the server: (but remember that this operation is mostly IO bound)
plug in more ram, get very fast raid 10 setup with 15krpm discs on a areca controller, etc. You get my drift.

User is offlineProfile CardPM
+Quote Post

mikeblas

RE: Inserting 25 Millions Records SQL Server Takes 3hrs.

21 May, 2008 - 04:50 PM
Post #7

D.I.C Regular
Group Icon

Joined: 8 Feb, 2008
Posts: 390



Thanked: 27 times
My Contributions
Dropping indexes before inserting and re-creating them aftewards may or may not be faster. It depends on the involved indexes and the state of the table before the operations were begun.

Similarly, you might or might not find Oracle to be faster; asserting that it's a solution to your problem sounds more like an religious admonishment rather than any helpful advice.

You don't explain, foxon177, how you're performing your inserts. You can find varying degrees of improvement by consdiering a few different things:

1) Use BULK INSERT or FastLoad for your inserts. This avoids repeated compiling and locking, and can optimize your load time substantially.

2) If you can't use BULK INSERT or FastLoad, then use a regular INSERT statements in large batches. Make sure you're using precompiled, parameterized statements.

3) Which version of SQL Server are you using? Some editions in some versions don't support built-in partitioning, but all versions of SQL Server do support logical partitioning. The idea is to build individual tables, then create a view over them. Partitioning is generally not useful for performance, however--it's almost always useful for maintenance, though.

4) Make sure you're using the appropriate logging mode on your database.


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 10:36PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month