exam questions

Exam 70-765 All Questions

View all questions & answers for the 70-765 exam

Exam 70-765 topic 2 question 4 discussion

Actual exam question from Microsoft's 70-765
Question #: 4
Topic #: 2
[All 70-765 Questions]

Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution. Determine whether the solution meets stated goals.
You manage a Microsoft SQL Server environment with several databases.
You need to ensure that queries use statistical data and do not initialize values for local variables.
Solution: You enable the PARAMETER_SNIFFING option for the databases.
Does the solution meet the goal?

  • A. Yes
  • B. No
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
PARAMETER_SNIFFING = { ON | OFF | PRIMARY} enables or disables parameter sniffing. This is equivalent to Trace Flag 4136.
SQL server uses a process called parameter sniffing when executing queries or stored procedures that use parameters. During compilation, the value passed into the parameter is evaluated and used to create an execution plan. That value is also stored with the execution plan in the plan cache. Future executions of the plan will re-use the plan that was compiled with that reference value.
References:
https://msdn.microsoft.com/en-us/library/mt629158.aspx

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
manik_k
4 years, 6 months ago
This is the most confusing topic: In short answer for this question is Yes. Parameter sniffing default setting is: NO(PARAMETER_SNIFFING=Yes), this means SQL server sniffs the parameter at the time of first execution. If you make this option to Yes (PARAMETER_SNIFFING=Yes) SQL server uses statistical data for plan. hope this makes sense..:-)
upvoted 3 times
Hoglet
4 years, 4 months ago
I think you’re confused there, the default is ON, not NO. The below is from the manual PARAMETER_SNIFFING = { ON | OFF | PRIMARY} Enables or disables parameter sniffing. The default is ON. Setting PARAMETER_SNIFFING to OFF is equivalent to enabling Trace Flag 4136.
upvoted 1 times
...
...
RohitRaj2311
4 years, 7 months ago
PARAMETER_SNIFFING means that it will use statistical data and not initialise value. Because if it will initialise values, we will always have a new plan for new values hence will never need parameter sniffing. So answer is A.
upvoted 2 times
...
DudeHere
5 years, 1 month ago
I would stick with YES as this option is mentioned in all studies. All other questions similar to this were obviously wrong. Using the parameter to build your execution plan would be a better idea; additionally it the source states the value would be stored which is the same as "do not initialize values for local variables"
upvoted 3 times
...
V_karag
5 years, 3 months ago
I think the correct answer is NO. When you disable PARAMETER_SNIFFING optimizer will use its statistical data instead looking for a variable, initialize it and pass it to optimizer. An article for reference. https://blog.sqlauthority.com/2019/12/20/sql-server-parameter-sniffing-and-local-variable-in-sp/
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago