Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Symptoms

Assume that you have applied Microsoft SQL Server 2012 Service Pack 2 (SP2) on your computer. You call the cdc.fn_cdc_get_net_changes_<capture_instance> Change Data Capture (CDC) query in the sp_executesql stored procedure, and it may come from an application source such as SQL Server Management Studio Server (SSMS), CDC itself, or the SQL Server Integration Services (SSIS) packages. In this situation, you experience poor performance in SQL Server 2012.

Note The decrease in performance could be large. For example, a query can finish in a few seconds in SQL Server 2012 SP1. However, the same query can take several hours to run in SQL Server 2012 SP2. Additionally, statistics update does not help with the problem.

Cause

This issue occurs because of a problem in Cardinality Estimation that severely affects the performance of the cdc.fn_cdc_get_net_changes_<capture_instance> query.

Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:


Workaround

To work around this issue, use the Option (Recompile) query hint in your query. In case the query is triggered from SSIS CDC components, the Option (Recompile) hint may be forced by creating a plan guide as in the following example:Exec sp_create_plan_guide
@name = N'CDC_Query1_PlanGuide',
@stmt = N'select [__$start_lsn],[__$operation],[__$update_mask],[Column1],[Column2],[Column3]
from [cdc].[fn_cdc_get_net_changes_dbo_Table1](CONVERT(binary(10), @cs, 1), CONVERT(binary(10), @ce, 1), @mode)',
@type = N'SQL',
@module_or_batch = NULL,
@params = N'@ce nvarchar(22),@mode nvarchar(14),@cs nvarchar(22)',
@hints = N'OPTION (RECOMPILE)'; Note You have to replace the example query with the query that you are facing issue with. It can be grabbed from the Profiler trace, so no extra character is accidentally added. Additionally, make sure that the SELECT query is put in a single line (for example, it should not have any carriage return or line feed) so that the plan guide can work successfully. You may also have to use DBCC FREEPROCCACHE to knock off the old plan from cache.

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×