70-465 · Question #75
You need to recommend a solution to minimize the amount of time it takes to execute USP_1. With what should you recommend replacing Table1?
The correct answer is D. A temporary table. To minimize execution time of USP_1, replacing Table1 with a temporary table is recommended because temporary tables support statistics, indexes, and parallel execution plans, which optimize query performance for procedural operations.
Question
Exhibits
Options
- AAn indexed view
- BA function
- CA table variable
- DA temporary table
How the community answered
(58 responses)- A16% (9)
- B7% (4)
- C3% (2)
- D74% (43)
Why each option
To minimize execution time of USP_1, replacing Table1 with a temporary table is recommended because temporary tables support statistics, indexes, and parallel execution plans, which optimize query performance for procedural operations.
An indexed view materializes query results but adds overhead for data modifications and is subject to strict requirements (e.g., schema binding), making it unsuitable as a direct replacement for a table used in procedural logic within a stored procedure.
A function (table-valued or scalar) introduces additional overhead and limitations such as restricted parallel execution and inability to maintain statistics, which would not minimize execution time.
Table variables do not maintain statistics and always estimate a single row cardinality, leading the optimizer to choose poor execution plans for larger datasets, which can significantly increase execution time rather than minimize it.
Temporary tables (created with # prefix in tempdb) support statistics generation, indexing, and parallel query execution plans, making them well-suited for optimizing stored procedure performance. Unlike table variables, temporary tables allow the query optimizer to generate accurate execution plans based on actual row counts and distribution statistics. This leads to significantly better performance when dealing with larger datasets or complex queries within stored procedures.
Concept tested: Temporary tables vs table variables for stored procedure performance optimization
Source: https://learn.microsoft.com/en-us/sql/relational-databases/tables/temporary-tables?view=sql-server-ver16
Topics
Community Discussion
No community discussion yet for this question.

