Skip to content

Commit 205e83f

Browse files
committed
Plan with Parameter greater than 8KB isn't persisted, thus compile lock
1 parent 92e2859 commit 205e83f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

support/sql/database-engine/performance/troubleshoot-blocking-caused-compile-locks.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Troubleshoot blocking issues caused by compile locks
33
description: This article describes how to troubleshoot and resolve blocking issues caused by compile locks.
4-
ms.date: 09/12/2024
4+
ms.date: 01/02/2025
55
ms.custom: sap:SQL resource usage and configuration (CPU, Memory, Storage)
66
---
77
# Troubleshoot blocking issues caused by compile locks
@@ -83,9 +83,11 @@ The solution is to drop and create the procedure by using the same letter case a
8383

8484
### Stored procedure is invoked as a Language event
8585

86-
If you try to execute a stored procedure as a Language Event instead of as an RPC, SQL Server must parse and compile the language event query, determine that the query is trying to execute the particular procedure, and then try to find a plan in cache for that procedure. To avoid this situation in which SQL Server must parse and compile the language event, make sure that the query is sent to SQL as an RPC.
86+
If you try to execute a stored procedure as a Language Event instead of as an RPC, SQL Server must parse and compile the language event query, determine that the query is trying to execute the particular procedure, and then try to find a plan in cache for that procedure. To avoid this situation in which SQL Server must parse and compile the language event, make sure that the query is sent to SQL Server as an RPC. For example in .NET code, you would use SqlCommand.CommandType.StoredProcedure to ensure an RPC event.
8787

88-
For more information, see the **System Stored Procedures** section in the Books Online article **Creating a Stored Procedure**.
88+
### Stored procedure or sp_executesql uses a string parameter greater than 8 KB
89+
90+
If you call a stored procedure or sp_executesql and pass a string parameter with a size larger than 8 KB, then SQL Server uses a binary large objects (BLOB) data type to store the parameter. As a result the query plan for this execution isn't persisted in plan cache. Therefore each and every execution of the stored procedure or sp_executesql has to acquire a compile lock to compile a new plan. This plan is discarded the moment execution completes. For more information, see the note in [Execution plan caching and reuse](/sql/relational-databases/query-processing-architecture-guide) regarding string literals larger than 8 KB in size. To avoid the compile lock in this scenario, reduce the size of the parameter to less than 8 KB.
8991

9092
## References
9193

0 commit comments

Comments
 (0)