Good afternoon, tell me, please, what is the SARG argument and how does the optimizer use it?

    1 answer 1

    SARG = Seekable ARGument, an argument that, when inserted into the WHERE allows you to use an index. For example:

     SELECT * FROM myTable WHERE id = 3; 

    can use the index on the id field, but:

     SELECT * FROM myTable WHERE (id * 3) = 3; 

    no, because you need to multiply each value of id in the table, which is equivalent to complete enumeration. NonSARG can greatly slow down the execution of your queries, especially often such arguments are obtained as a result of casting tuple values ​​to another type.

    • It seems to be a Search Argument, so it is an internal parameter (since it is not visible SAGR query or NonSARG) optimizer to determine the possibility of using the index? - Nick Proskuryakov
    • @ WizarD51 1. Search / Seek - synonyms :) 2. For NonSARG, the optimizer simply cannot use the index. Or I do not understand your difficulties? - Mirdin
    • Everything is ok, thanks) - Nick Proskuryakov