加快資料倉儲載入無需添加硬體的解決方案

來源:互聯網
上載者:User

很多公司流行使用資料倉儲進行資料分析,一般從線上資料來源備庫(mirror,logshipping,slave等)抽取到ods 層

在從ods層到dw再到dm.特別在ods層到dw時,資料的清洗裝載需要一定的時間和硬體資源.

但是當硬體成為瓶頸時,怎麼能快速完成清洗轉載,及時的提供資料分析?

下面提供一種方法使用Ssis 載入到 ods層後,直接通過分區表把資料載入到 dw 

1 準備

 
  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 使用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 

對傳輸過來的表進行分區

 
  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)

把分區partition 2指向給 dw 值得注意的是 accountdetail_dw 必須跟partition 2 分區所在同一個檔案組

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

整個過程在 5分鐘內.資料倉儲最重要的還在當初的設計和選型.

原文標題:當硬體成為瓶頸時怎麼提高資料倉儲的載入?

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.