Home Forums SQL Server 2008 SQL Server 2008 - General What is proper way of indexing on a table which contain large amount of data RE: What is proper way of indexing on a table which contain large amount of data

  • I was just reading the article:

    http://www.sql-server-performance.com/2007/t-sql-where/2/[/url]

    There is a recommendation given below:

    "If you have a WHERE clause that includes expressions connected by two or more AND operators, SQL Server will evaluate them from left to right in the order they are written. This assumes that no parenthesis have been used to change the order of execution. Because of this, you may want to consider one of the following when using AND:

    Locate the least likely true AND expression first. This way, if the AND expression is false, the clause will end immediately, saving time.

    If both parts of an AND expression are equally likely being false, put the least complex AND expression first. This way, if it is false, less work will have to be done to evaluate the expression.

    You may want to consider using Query Analyzer or Management Studio to look at the execution plans of your queries to see which is best for your situation. [2000, 2005, 2008] Updated 2-4-2009 "

    Check the above bold line.

    So, if we put least likely true column very first (left most where clause), then it is just opposite which you have asked.

    You advised that we should put "most selective" column first.

    Now I am in dilemma. What to do, what not to do.