How to accelerate data warehouse loading without adding hardware

Source: Internet
Author: User

Many companies use data warehouses for data analysis. Generally, they extract data from online backup databases (such as mirror, logshipping, and slave) to the ods layer.

From the ods layer to dw to dm, especially from the ods layer to dw, data cleaning and loading takes some time and hardware resources.

But when the hardware becomes a bottleneck, how can we quickly complete cleaning and reprinting and timely provide data analysis?

The following provides a method to load data to the ods layer using Ssis directly through a partition table

1 Preparation

 
 
  1.  /*create filegroup*/  
  2.   ALTER DATABASE [testxwj] ADD FILEGROUP [account_1]   
  3.  go   
  4. ALTER DATABASE [testxwj] ADD FILEGROUP [account_2]   
  5. go   
  6. ALTER DATABASE [testxwj] ADD FILEGROUP [account_3]  
  7.  
  8. /*create file to filegroup*/  
  9.  
  10. ALTER DATABASE [testxwj] ADD FILE ( NAME = N'account_1', FILENAME = N'E:\account_1.ndf' , SIZE = 409600KB , FILEGROWTH = 20480KB ) TO FILEGROUP [account_1]  
  11.   GO  
  12. ALTER DATABASE [testxwj] ADD FILE ( NAME = N'account_2', FILENAME = N'E:\account_2.ndf' , SIZE = 409600KB , FILEGROWTH = 20480KB ) TO FILEGROUP [account_2]  
  13.  GO  
  14. ALTER DATABASE [testxwj] ADD FILE ( NAME = N'account_3', FILENAME = N'E:\account_3.ndf' , SIZE = 409600KB , FILEGROWTH = 20480KB ) TO FILEGROUP [account_3]  
  15. GO16 

2 Use ssis copy table

 
 
  1. sp_spaceused accountdetail; 

 
 
  1. /* delete EarnTime is not null*/   
  2.  
  3. /*23 sec*/   
  4. delete from accountdetail where EarnTime is null 
  5. /*26 sec*/   
  6. delete from accountdetail where isnull(CommitStatus,0)<1   
  7. /*12 sec*/  
  8. delete from accountdetail where  isnull(EarnStatus,0) =0 

Partition the transmitted table

 
 
  1. /*create partition function*/  
  2. declare @bdate char(8),@edate varchar(8),@sql varchar(500)   
  3. select   
  4. @bdate=convert(char(8),GETDATE()-1 ,112)   
  5. ,@edate=convert(char(8),GETDATE() ,112)   
  6. select @bdate,@edate;  
  7. set @sql='   
  8. CREATE PARTITION FUNCTION ac_EarnTime (datetime)  
  9. AS11 RANGE RIGHT FOR VALUES ( '''+@bdate+''' ,'''+@edate+''')'  
  10.  execute(@sql)  
  11. /*create partition schema*/  
  12. CREATE PARTITION SCHEME ac_schema_ac_EarnTime
  13. AS PARTITION ac_EarnTime TO (account_1,account_2,account_3);  
  14. /*create partition table */  
  15. alter table accountdetail  
  16. alter column EarnTime datetime not null;  
  17. alter TABLE accountdetail  
  18. add CONSTRAINT [PK_PARTITIONmis] PRIMARY KEY 
  19. (   id,EarnTime
  20.  )ON ac_schema_ac_EarnTime(EarnTime)

Point partition 2 to dw. It is worth noting that accountdetail_dw must be in the same file group as partition 2.

 
 
  1. /*switch accountdetail to accountdetail_dwl*/  
  2.  ALTER TABLE accountdetail SWITCH PARTITION 2 TO accountdetail_dw ;  
  3. /**/ 

The entire process is within five minutes. The most important part of the data warehouse is the original design and selection.

Original article title: how to improve data warehouse loading when hardware becomes a bottleneck?

Link: http://www.cnblogs.com/xwj1985/archive/2010/08/19/1803272.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.