Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Fastest way to copy data?

Author  Topic 

matty1stop
Starting Member

37 Posts

Posted - 2007-05-22 : 08:50:52
I've got a view that is driven from a 80 million record table in a data warehouse. I am trying to populate an aggregate table in a datamart, but am running into preformance problems. The datamart table needs to be updated daily. I understand there are many factors that effect performance, but in general would the fastest approach be:
1) Truncate the datamart table
2) Perform a bcp of the view to a text file
3) Bulk Insert to the datamart table

If you need more information to answer this please let me know.

Thanks,

Matt

sshelper
Posting Yak Master

216 Posts

Posted - 2007-05-22 : 09:01:13
One thing you can also try is to remove the indexes of your datamart table, insert your records to it, then re-create all your indexes.

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page

matty1stop
Starting Member

37 Posts

Posted - 2007-05-22 : 09:19:59
I'm running the bcp export now. It has been running for over an hour with no change to the size of the text file it is writing to.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-22 : 09:24:58
Do you have a last change datetime column in the source table ? If not why not create one ? This will help in determine which are the records that was modified since you last import to the target.


KH

Go to Top of Page

rudesyle
Posting Yak Master

110 Posts

Posted - 2007-05-22 : 10:56:28
One thing that helped me one time was to not use a view, meaning, I just copied the sql into my script. I saw a signifacnt performance increase.

Just something to try, not knowing your view or anything...
Go to Top of Page

matty1stop
Starting Member

37 Posts

Posted - 2007-05-22 : 13:11:18
The BCP finally finished. Took 3 hours to export 3 million records

I was hoping for a way to somehow get this feed down to minutes instead of hours.
Go to Top of Page

rudesyle
Posting Yak Master

110 Posts

Posted - 2007-05-22 : 15:36:37
quote:
Originally posted by matty1stop

The BCP finally finished. Took 3 hours to export 3 million records

I was hoping for a way to somehow get this feed down to minutes instead of hours.


Post your Sql. That's too long for inserts. Make sure to drop the indexes too, and then re-add them after the batch is done.
Go to Top of Page

matty1stop
Starting Member

37 Posts

Posted - 2007-05-22 : 15:39:22
That was 3 hours for the Export not the Insert.
Go to Top of Page
   

- Advertisement -