Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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://www.brentozar.com/blitzcache/non-sargable-predicates...





Looking up the etymology of "sargeable", I found this StackOverflow answer: 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."


I'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.)


Brent Ozar isn't guessing about MS SQL Server... he knows the eval engine inside and out.

I 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.


I'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?


My guess is mssql as I've seen the term quite a bit with those guys.

Oracle, DB2, SQl Server... I've seen in the more Enterprise targeted docs for Postgres.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: