You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|Message Text|A possible infinite recompile was detected for SQLHANDLE %hs, PlanHandle %hs, starting offset %d, ending offset %d. The last recompile reason was %d.|
26
-
27
-
## Explanation
28
-
One or more statements caused the query batch to recompile at least 50 times. The specified statement should be corrected to avoid further recompilations.
29
-
30
-
The following table lists the reasons for recompilation.
31
-
32
-
|Reason code|Description|
33
-
|---------------|---------------|
34
-
|1|Schema changed|
35
-
|2|Statistics changed|
36
-
|3|Deferred compile|
37
-
|4|Set option changed|
38
-
|5|Temp table changed|
39
-
|6|Remote rowset changed|
40
-
|7|For Browse permissions changed|
41
-
|8|Query notification environment changed|
42
-
|9|Partition view changed|
43
-
|10|Cursor options changed|
44
-
|11|Option (recompile) requested|
45
-
|12|Parameterized plan flushed|
46
-
|13|Test plan linearization|
47
-
|14|Plan affecting database version changed|
48
-
|15|Query Store plan forcing policy changed|
49
-
|16|Query Store plan forcing failed|
50
-
|17|Query Store missing the plan|
51
-
|18|Interleaved execution required recompilation|
52
-
|19|Not a recompile|
53
-
|20|Query Store hints changed|
54
-
55
-
## User Action
56
-
57
-
1. View the statement causing the recompilation by running the following query. Replace the *sql_handle*, *starting_offset*, *ending_offset*, and *plan_handle* placeholders with the values specified in the error message. The **database_name** and **object_name** columns are NULL for ad hoc and prepared [!INCLUDE[tsql](../../includes/tsql-md.md)] statements.
58
-
59
-
```sql
60
-
SELECT DB_NAME(st.dbid) AS database_name,
61
-
OBJECT_NAME(st.objectid) AS object_name,
62
-
st.text
63
-
FROMsys.dm_exec_query_statsAS qs
64
-
CROSS APPLY sys.dm_exec_sql_text (0x01000600B74C2A1300D2582A2100000000000000000000000000000000000000000000000000000000000000 /* replace the 0x01000600B... value with the actual sql_handle*/) AS st
65
-
WHEREqs.statement_start_offset=123/*replace 123 with actual starting_offset value*/
66
-
ANDqs.statement_end_offset=456/*replace 456 with actual ending_offset value*/
67
-
ANDqs.plan_handle= 0x06000100A27E7C1FA821B10600 /*replace 0x06000100A27E7C1FA821B10600with actual plan_handle value*/;
68
-
```
69
-
70
-
2. Based on the reason code description, modify the statement, batch, or procedure to avoid recompilations. For example, a stored procedure may contain one or more SET statements. These statements should be removed from the procedure. For additional examples of recompilation causes and resolutions, see [Batch Compilation, Recompilation, and Plan Caching Issues in SQL Server 2005](/previous-versions/sql/sql-server-2005/administrator/cc966425(v=technet.10)).
71
-
72
-
3. If the problem persists, contact Microsoft Customer Support Services.
| Symbolic Name | PR_POSSIBLE_INFINITE_RECOMPILE |
27
+
| Message Text | A possible infinite recompile was detected for SQLHANDLE %hs, PlanHandle %hs, starting offset %d, ending offset %d. The last recompile reason was %d. |
28
+
29
+
## Explanation
30
+
31
+
One or more statements caused the query batch to recompile at least 50 times. The specified statement should be corrected to avoid further recompilations.
32
+
33
+
The following table lists the reasons for recompilation.
| 22 | Query Store recompiling to capture cursor query |
59
+
| 23 | Recompiling to clean up the multiplan dispatcher plan |
60
+
61
+
To view all compilation codes, run the following dynamic management view query:
62
+
63
+
```sql
64
+
SELECT*FROMsys.dm_xe_map_values
65
+
WHERE name LIKE'%compile%cause%';
66
+
```
67
+
68
+
## User action
69
+
70
+
1. View the statement causing the recompilation by running the following query. Replace the *sql_handle*, *starting_offset*, *ending_offset*, and *plan_handle* placeholders with the values specified in the error message. The `database_name` and `object_name` columns are `NULL` for ad hoc and prepared [!INCLUDE [tsql](../../includes/tsql-md.md)] statements.
/* replace the 0x01000600B... value with the actual sql_handle */
79
+
) AS st
80
+
WHEREqs.statement_start_offset=123/* replace 123 with actual starting_offset value */
81
+
ANDqs.statement_end_offset=456/* replace 456 with actual ending_offset value */
82
+
ANDqs.plan_handle= 0x06000100A27E7C1FA821B10600; /* replace 0x06000100A27E7C1FA821B10600 with actual plan_handle value */
83
+
```
84
+
85
+
1. Based on the reason code description, modify the statement, batch, or procedure to avoid recompilations. For example, a stored procedure might contain one or more `SET` statements. These statements should be removed from the procedure.
86
+
87
+
For more examples of recompilation causes and resolutions, see [Batch Compilation, Recompilation, and Plan Caching Issues in SQL Server 2005](/previous-versions/sql/sql-server-2005/administrator/cc966425(v=technet.10)). For more information on recompilations, see [Recompile execution plans](../query-processing-architecture-guide.md#recompiling-execution-plans).
88
+
89
+
1. If the problem persists, contact Microsoft Customer Support Services.
0 commit comments