70-473 · Question #113
Your company identifies a stored procedure that runs slowly. You review the execution plan for the stored procedure, and you discover the properties of a Clustered Index Scan operator as shown in…
The correct answer is B. Add a NOLOCK query hint to the SELECT statement. To improve the performance of a slow stored procedure that includes a Clustered Index Scan, especially if blocking or contention is a suspected cause, add the NOLOCK query hint to the SELECT statement.
Question
Options
- AAdd a FORCESEEK query hint to the SELECT statement.
- BAdd a NOLOCK query hint to the SELECT statement.
- CConvert the table to an In-Memory OLTP optimized table.
- DChange the FileName column from varchar(512) to nvarchar(512).
How the community answered
(25 responses)- A4% (1)
- B68% (17)
- C16% (4)
- D12% (3)
Why each option
To improve the performance of a slow stored procedure that includes a Clustered Index Scan, especially if blocking or contention is a suspected cause, add the NOLOCK query hint to the SELECT statement.
A FORCESEEK query hint forces the query optimizer to use an index seek operation; while a clustered index scan can be inefficient, FORCESEEK is used for incorrect index selection, not contention-based slowness.
The NOLOCK query hint allows a SELECT statement to read data without acquiring shared locks and without waiting for exclusive locks held by other transactions. If the stored procedure is running slowly due to contention or blocking caused by other operations holding locks on the underlying table, NOLOCK can significantly improve performance by eliminating these waits, albeit at the risk of reading uncommitted data.
Converting the table to an In-Memory OLTP optimized table requires significant schema and application changes and is a much more complex solution than a query hint for immediate slowness, especially if locking is the issue.
Changing the FileName column from varchar(512) to nvarchar(512) primarily affects storage for Unicode characters and collation, not query execution plan efficiency or locking contention.
Concept tested: Improving SQL Server query performance with NOLOCK hint
Source: https://learn.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-ver16#readpast-nolock
Topics
Community Discussion
No community discussion yet for this question.