covering indexes

  • If I have a table section

    sectionid, sectionname,parentsection,sectionstatus,deleted

    sectionid is my primary key

    the following query shows up a lot

    search for sections where sectionstatus!=2 and deleted=0 and (sectionid=@sectionid or parentsectionid=@sectionid)

    and query shows a lot

    where sectionstatus!=2 and deleted=0

    which is better

    to create a noncluster index on sectionid,parentsection,sectionstatus and delete all together

    or noncluster index on sectionstatus, deleted and include the columns sectionid and parentsection

    Thanks

  • Safe to assume your Primary Key is also your Clustered index?


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Yes my primary key is clustered index

  • I would add a non-clustered index on parentsectionid alone and see how that works out. Another option is to include the sectionid in that index.

    My guess is that the selectivity of these columns would make it more effective that indexing the other columns.

    The probability of survival is inversely proportional to the angle of arrival.

  • Unfortunately, no one is asking the obvious question. What is the problem you are having or trying to solve?

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply