문제

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.

도움이 되었습니까?

해결책

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:

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top