4 ms·
The single biggest thing that helped me speed up my queries and lower resource usage on the server was focusing on making my queries more sargable. https://en.
by FuriouslyAdrift 1y ago
The single biggest thing that helped me speed up my queries and lower resource usage on the server was focusing on making my queries more sargable.
https://en.wikipedia.org/wiki/Sargable https://en.wikipedia.org/wiki/Sargable
https://www.brentozar.com/blitzcache/non-sargable-predicates/ https://www.brentozar.com/blitzcache/non-sargable-predicates...
- jdnier 1y agoLooking up the etymology of "sargeable", I found this StackOverflow answer: https://dba.stackexchange.com/a/217983 https://dba.stackexchange.com/a/217983 And Google explains "The term 'sargable' is a portmanteau of "Search ARGument ABLE," formed by combining the words from a SQL database context."
- crazygringo 1y agoI'm really curious, what communities use that word? I've been working with SQL for 20+ years, and have literally never come across that word a single time in any documentation, tutorial, Stack Overflow answer, or here on HN. Working in Postgres, MySQL and SQLite. Is it used at some particular company, or open source community, or with a particular database, or something?
- cowboylowrez 1y agoMy guess is mssql as I've seen the term quite a bit with those guys.
- FuriouslyAdrift 1y agoOracle, DB2, SQl Server... I've seen in the more Enterprise targeted docs for Postgres.
- MaxBarraclough 1y agoI'm sceptical of that article, it's making guesses about the limitations of SQL query optimisers. Consider the Simple example it presents. The article is in effect implying that no query optimiser would be able to figure out the equivalence of the two predicates. (Let's ignore that the two predicates aren't actually equivalent; the first version may raise an exception if myIntColumn is negative, depending on the DBMS.)
- FuriouslyAdrift 1y agoBrent Ozar isn't guessing about MS SQL Server... he knows the eval engine inside and out.
- MaxBarraclough 1y agoI should have been clearer, I meant the Wikipedia article. Ozar's article is much better. It doesn't make sweeping assumptions about the limitations of all query optimisers, or basic oversights in contrasting supposedly equivalent predicates.