• ANn -425914 (2/27/2015)


    Thanks, a little not clear,

    For our case I first created an index on terms table by using ID, SchoolID,

    Note the ID is not a clustered index, there is another prirmay key column called DCID. ID is not even an index. (This is vendors database.)

    But a lot of functions using below join, schoolID first, then terms.ID second

    ....

    Inner Join Terms t On t.schoolid = 0 --

    And t.id = get_current_school_year

    So I ended up to change the order for the index to SchoolID + ID.

    For my case, the program runs almost the same time comparing with the two different orders, but I am just interested if this is always true that order makes little difference

    And do you think which order is better for our case.

    Thanks

    I would put it back the way it was because ID is more selective than SchoolID and you are using both columns in the criteria of the query you've given.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)