What is SARGability and why is it critical for performance?

Senior MS SQL

Answer

SARGability (Search ARGument-ability) describes whether a predicate can efficiently use an index to seek rows instead of scanning.

SARGable predicates:

  • Simple comparisons like Column = @Value, Column >= @Start AND Column <= @End.
  • Allow the optimizer to perform index seeks and range scans.

Non-SARGable patterns:

  • Applying functions to columns: WHERE LOWER(Col) = 'abc'.
  • Expressions on the left side: WHERE Col + 1 = 10.
  • Implicit conversions that change the column's data type.
  • Leading wildcards: LIKE '%abc'.

Ensuring predicates are SARGable is one of the most impactful techniques in query tuning: it allows indexes to be used effectively, minimizing reads and dramatically improving performance.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice