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 4053160
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:24:42+00:00 2026-05-20T14:24:42+00:00

should you index a many to many table such as user_role where it has

  • 0

should you index a many to many table such as user_role where it has 2 fields (userId and RoleId) ?

and what kind of index would be best?

  • 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-20T14:24:43+00:00Added an answer on May 20, 2026 at 2:24 pm

    It depends. If there are a lot of user/role combinations (tens of thousands or more), and you are querying this information a lot, or need it to be particularly performant, then yes.

    If there are not very many records, or you don’t care if it’s very performant, or don’t use it very often, then most likely no.

    For the usage part, SQL Server can help you decide if this is used enough to warrant an index. See here for some guidance.

    Also, as Martin pointed out, if you have defined user/role as a primary key on this table, you already have an index, the clustered index, for that combination of columns.

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

Sidebar

Related Questions

Should I be careful adding too many include columns to a non-cluster index? I
I have a user table that has many columns, it looks roughly like this:
RewriteEngine on RewriteCond %{REQUEST_URI} !^/index\.php RewriteRule ^(.*)$ index.php?q=$1 [L] This should rewrite any url
Should I still be using tables anyway? The table code I'd be replacing is:
I m using one-to-many mapping for List using join table. There are lot of
Suppose I have a table with full-text index on column Firstname, lastname, email. There
The table: id | category (there is a index on id & category) -----------
I have a table of messages Key - UserId, MsgIndex C1...Cn - some data
A relation table is the common solution to representing a many-to-many (m:n) relationship. In
Lets say I have a simple many-to-many table between tables table1 and table2 that

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.