Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 356289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:05:51+00:00 2026-05-12T12:05:51+00:00

I have a N to N table with columns: Id (primary key) (I need

  • 0

I have a N to N table with columns:

Id (primary key) (I need this for various reasons)
ClientId
FeatureId

Queries use all combinations of ClientId and FeatureId and need to be quick for all cases. (ClientId+FeatureId, ClientId, FeatureId)

My idea is to create a covered clustured index on ClientId and FeatureId and additional noncovered indexes on ClientId and FeatureId individually? Does this make sense?

Also, I’ve read somewhere if I create the covered index in the order ClientId, FeatureId I dont have to create and individual index for FeatureId?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:05:52+00:00Added an answer on May 12, 2026 at 12:05 pm

    I am assuming that the output from the query is clientid and featureid – not the ID field.
    If you do need this as well, I would suggest investigating ‘included columns’.

    A covering index on (clientid, featureid)

    create index idx_covering on mytable(clientid,featureid)
    

    will result in an INDEX SEEK for both clientid+featureid and clientid queries, with and INDEX SCAN for the featureid query.

    Even with another index, just for featureid, the covering index will be used, as the query needs to return both the clientid and featuredid (as per my above assumption).

    To get an index seek, create an index with included columns

    create index idx_feature_withincluded on mytable(featureid) include (clientid)
    

    Whether or not it is better to have 1 or 2 indexes really depends on your environment – the tradeoff is bewteen maintainability and performance. For every UPDATE and INSERT, the indexes will be updated, but if that is a small overhead in regards to the amount of SELECTs then thats good for you.

    It’s one of those things that can only really be answered by implementing one way, monitoring and adjusting. Even if you hit an optimum solution, further increase in data volumes or application use can significantly change the way the database performs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with say 3 columns. There's no primary key so there
I have a table with a clustered primary key index on a uniqueidentifier column.
I have a table with columns ID, DateStamp and the ID need not be
I have a table with arbitrary columns and rows. This fact is irrelevant though
I have my table columns set like this: likes(id, like_message, timestamp) id is the
I have a table with columns Index, Date where an Index may have multiple
I have a table with three columns: user varchar, status varchar , rep int
I have a table with four columns: PartNumber, ValvePartNumber, ActuatorPartNumber, Price I want to
Let's say I have a table tbl with columns id and title . I
I have a table y Which has two columns a and b Entries are:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.