Pregunta

I am looking for a technical term that describes the type of query in SQL that makes use of indexes. I completely forgot the name and can not look it up anymore (there's even a Wikipedia article about that, but I can't find it). It has (AFAIK) two or three syllables.

It basically denotes the type of query that makes use of indexes, and constitues of best practices to use when querying the database.

Some of the best practices are these:

  • do not search by perform functions or computations on column names
  • do use LIKE operator with trailing wildcards, not leading
  • compare column value to fixed value (constant),

Eg.

SELECT column, date FROM table (..)

(..) WHERE column LIKE 'A%' -- OK, because looks up the column
(..) WHERE column LIKE '%A%' -- INCORRECT, expensive
(..) WHERE SUBSTRING(column, 1, 3) = 'abc' -- INCORRECT

Do you know what's the term describing these types of queries?

Thanks.

¿Fue útil?

Solución

Sargable (or sometimes sargeable). It's not really a word, it's made up of Search ARGument, and when a WHERE clause is sargable, that mean's it's possible for it to use an index. It doesn't mean it will use the index, and it doesn't mean it will seek, either. A lot of factors go into the optimizer's choice, and the rules can clearly differ between different platforms, and even different versions and editions of the same platform.

References:

Licenciado bajo: CC-BY-SA con atribución
No afiliado a dba.stackexchange
scroll top