cdc performance turning and monitor

https://msdn.microsoft.com/en-us/library/dd266396.aspx
https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/administer-and-monitor-change-data-capture-sql-server#Capture

USE msdb;  


DECLARE @schedule_uid uniqueidentifier;  
DECLARE @collection_set_id int;  


DECLARE @cid int;  


DECLARE @pp xml = CONVERT(xml,   
    N'<ns:TSQLQueryCollector xmlns:ns="DataCollectorType">  
        <Query>  
          <Value>SELECT * FROM sys.dm_cdc_log_scan_sessions</Value>  
          <OutputTable>cdc_log_scan_data</OutputTable>  
        </Query>  
      </ns:TSQLQueryCollector>');  




-- Collect and upload data every 5 minutes  
SELECT @schedule_uid = (  
SELECT schedule_uid from sysschedules_localserver_view   
WHERE name = N'CollectorSchedule_Every_5min')  


EXEC dbo.sp_syscollector_create_collection_set  
@name = N' CDC Performance Data Collector',  
@schedule_uid = @schedule_uid,          
@collection_mode = 0,                   
@days_until_expiration = 30,                
@description = N'This collection set collects CDC metadata',  
@collection_set_id = @collection_set_id output;  




print @collection_set_id ;




-- Create a collection item using statistics from   
-- the change data capture dynamic management view.  


 


EXEC dbo.sp_syscollector_create_collection_item  
@collection_set_id = @collection_set_id,  
@collector_type_uid = N'302E93D1-3424-4BE7-AA8E-84813ECF2419',  
@name = ' CDC Performance Data Collector',  
@frequency = 5,   
@parameters = @pp,  
@collection_item_id = @cid output;  
print @cid
GO  




--sp_syscollector_delete_collection_item   @name = N' CDC Performance Data Collector'
--sp_syscollector_delete_collection_set @name = N' CDC Performance Data Collector'

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16131092/viewspace-2143563/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/16131092/viewspace-2143563/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值