This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
Illustrated cover: Stream vs Hash Aggregate

SQL SERVER – Stream Aggregate and Hash Aggregate

February 17, 2020
Pinal Dave
SQL Performance
Execution Plan, MAXDOP, Parallel, Query Hint, SQL Group By, SQL Operator, SQL Server Management Studio

Recently during the on-demand consultation, I was asked a very interesting question about Stream Aggregate and Hash Aggregate.

Read More
Gouache painting of a beagle sitting beside a wicker picnic basket with a vermilion cloth, looking away

DISABLE_PARAMETER_SNIFFING Hint: Turn Off Sniffing for One Query

February 12, 2020
Pinal Dave
SQL Performance
Execution Plan, Parameter Sniffing, Query Hint, SQL Scripts, SQL Stored Procedure

The DISABLE_PARAMETER_SNIFFING hint makes one query ignore the parameter value it was first compiled for. This post compares it with the default, OPTIMIZE FOR UNKNOWN and RECOMPILE on a table where one customer owns 40 percent of the rows. The reads show which variant fits which workload.

Read More
Gouache painting of three fresh rolls in a vermilion basket on a counter in front of a tray of dough still waiting

OPTION FAST N: First Rows Sooner, Total Reads Higher

February 11, 2020
Pinal Dave
SQL Performance
Execution Plan, Query Hint, SQL Scripts, SQL Server

OPTION FAST N tells SQL Server to plan for the first N rows, so the first rows arrive in milliseconds and the whole result costs much more. This post measures both sides on 300,000 rows with logical reads and time to the first row. It also explains why the hint belongs to paging and not to tuning.

Read More
Gouache painting of a basket of red apples under an apple tree in an orchard row

DISABLE_OPTIMIZER_ROWGOAL: How a Row Goal Changes the Plan

February 7, 2020
Pinal Dave
SQL Performance
Execution Plan, Query Hint, SQL Scripts, SQL Server

DISABLE_OPTIMIZER_ROWGOAL switches off a row goal, the optimizer’s bet that a query needs only a few rows, and TOP, FAST, IN and EXISTS all place that bet. This post reads the estimates behind it, shows how the plan shape changes, and shows when the bet fails. A covering index fixes the failure, and the hint does not.

Read More
Gouache painting of four garden tools hanging on a rail, the second one a vermilion trowel and the others grey and sage

Parameter Sniffing Fixes Compared: Which One to Use

January 1, 2020
Pinal Dave
SQL Performance
Parameter Sniffing, Query Hint, Recompile, SQL Scripts, SQL Stored Procedure

Parameter sniffing fixes compared on one table show a clear order, from a cheap guess to a better index. This post runs the plain procedure, a local variable, OPTIMIZE FOR UNKNOWN, a scoped setting, OPTION (RECOMPILE) and a covering index on the same skewed table, and prints the page reads of each in both call orders.

Read More
Gouache painting of a fresh pattern sheet pinned on cloth with vermilion scissors beside a pile of crumpled old patterns

OPTION (RECOMPILE) Hint: When a Fresh Plan Pays Off

December 31, 2019
Pinal Dave
SQL Tips and Tricks
Parameter Sniffing, Query Hint, Recompile, SQL Scripts, SQL Stored Procedure

The OPTION (RECOMPILE) hint tells SQL Server to build a new plan every time a statement runs. This post measures the page reads it saves on skewed data, the compile cost it adds, the filtered index it unlocks, and how to apply it to one statement of a procedure.

Read More
Gouache painting of a railway junction where a vermilion switch lever sends a small handcar onto a short siding ending at a buffer stop.

ABORT_QUERY_EXECUTION: Stopping a Runaway Query With a Query Store Hint

November 8, 2019
Pinal Dave
SQL Performance
Query Hint, Query Store, SQL Performance, SQL Scripts

ABORT_QUERY_EXECUTION is a SQL Server 2025 Query Store hint that makes one known bad query fail before it uses any CPU. This post sets the hint, shows the exact error the caller gets, lists and clears the hint, and covers the traps: exact text, SET options and queries already running.

Read More
Previous 1 2 3 4 5 6 7 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com