开发者

How to capture actual execution plan in a deadlock graph?

开发者 https://www.devze.com 2023-03-28 08:56 出处:网络
Is there any o开发者_JAVA技巧ption or any setting by which SQL Server can dump the actual execution plan (at that instance) for stored procs involved in a deadlock?

Is there any o开发者_JAVA技巧ption or any setting by which SQL Server can dump the actual execution plan (at that instance) for stored procs involved in a deadlock?

This is in context of SQL Server 2008.


Capture the SQL and plan handle and then you might get the query execution plan from the plan cache.

Here's how to capture a deadlock graph before it happens.

  1. Start SQL Server Profiler. On the File menu, click New Trace, and then connect to an instance of SQL Server. Give the trace a name and pick one of the trace templates.

How to capture actual execution plan in a deadlock graph?

  1. Do one of the following:

    • Select the Save to file check box to capture the trace to a file. Specify a value for Set maximum file size. Optionally, select Enable file rollover and Server processes trace data.

    • Select the Save to table check box to capture the trace to a database table. Optionally, click Set maximum rows, and specify a value.

  2. Optionally, select the Enable trace stop time check box, and specify a stop date and time.

  3. Select the Events Selection tab. Check Show All Events. In the Events data column, expand the Locks event category, and then select the Deadlock graph check box.

How to capture actual execution plan in a deadlock graph?

  1. The Events Extraction Settings tab is added to the Trace Properties dialog box.

  2. On the Events Extraction Settings tab, click Save Deadlock XML Events Separately. In the Save As dialog box, enter the name of the file in which to store the deadlock graph events.

  3. Click All Deadlock XML batches in a single file to save all deadlock graph events in a single XML file, or click Each Deadlock XML batch in a distinct file to create a new XML file for each deadlock graph.

How to capture actual execution plan in a deadlock graph?

After you have saved the deadlock file, you can open the file in SQL Server Management Studio.

  • How to: Open, View, and Print a Deadlock File (SSMS)

  • Analyzing Deadlocks with SQL Server Profiler

  • How to: Save Deadlock Graphs (SQL Server Profiler)

  • Deadlock Graph Event Class

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号