Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Identify use cases for intelligent query processing (IQP) features

A worked example

Single answer

A vendor application runs on an Azure SQL Database. The vendor requires the database to stay at compatibility level 140, and you may not change any T-SQL code. A slow query joins a table to a multi-statement table-valued function that returns tens of thousands of rows. The query uses no scalar functions and no table variables of its own. The execution plan shows that the optimizer assumed the function returns very few rows. The query does not spill to tempdb, and its memory grant is adequate.

Which intelligent query processing feature is designed to improve the plan for this query?

Choose one answer
Why

Multi-statement table-valued functions used a fixed small row estimate, which can produce a poor plan when the function returns many rows. Interleaved execution obtains the actual row count from the function before compiling the rest of the plan. Compatibility level 140 enables interleaved execution by default for eligible queries, so the feature can improve the plan without a compatibility-level or code change. The other features target memory grants, table variables, scalar functions or distinct counts.

  • Not correct: Table variable deferred compilation. Deferred compilation gives table variables an actual row count at first compilation; the poor estimate here comes from the multi-statement table-valued function, which interleaved execution handles.
  • Correct: Interleaved execution. For an eligible query, interleaved execution gets the actual row count from the multi-statement table-valued function before compiling the rest of the plan. The feature is enabled by default at compatibility level 140 or higher.
  • Not correct: Memory grant feedback. Memory grant feedback corrects over- or under-sized memory grants; the scenario states the grant is adequate and there are no spills.
  • Not correct: Scalar user-defined function inlining. Inlining transforms scalar user-defined functions into subqueries; the query calls a table-valued function, not a scalar one.
  • Not correct: Approximate count distinct. Approximate count distinct is a function the query must call to get a faster distinct count, so it needs a code change and does not address the row estimate.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free