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

  • Home
  • SEARCH
  • 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 7932347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:59:21+00:00 2026-06-03T20:59:21+00:00

Q1 : Is it worthwhile to create indexes for foreign key columns in a

  • 0

Q1: Is it worthwhile to create indexes for foreign key columns in a SQL Server database?

Q2: If I have two related tables in a SQL Server database and I want to create an index on the foreign key column to improve performance, which columns do I need to include in the index and what type of index is best suited?

For example…

Table1

Table1ID int (Primary Key)

Table2

Table2ID int (Primary key)
Table1ID int (Foreign key)

..Would I create an Index for Table2 just with Table1ID or do I need to include the primary key (Table2ID) as well.

Q3: If I extend the example to include a third table which is related to both Table1 and Table2, do I create one index for each column or one index with both columns?

Table3

Table3ID int (Primary key)
Table1ID int (Foreign key)
Table2ID int (Foreign key)

  • 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-06-03T20:59:22+00:00Added an answer on June 3, 2026 at 8:59 pm

    Q1. Yes. (You can always remove them later if you find they are not being used regularly).

    Q2. Would I create an Index for Table2 just with Table1ID? Yes. Assuming the primary intended use of the index is to help the optimiser with joins between these 2 tables. (Rather than satisfy some other query that is part of your overall query workload).

    Q3. Yes. Each column with a foreign key should have a separate index to its its parent key table.

    (All assuming you have an OLTP database rather than an OLAP database)

    This post provides TSQL that will generate a script of all the missing Foreign key indexes in a database: TSQL: Generate Missing Foreign Key Indexes

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

Sidebar

Related Questions

I have been learning about indexes in Oracle SQL, and I wanted to conduct
I've been using c# since version 1, and have never seen a worthwhile use
I currently am working on a legacy application and have inherited some shady SQL
I have an ActiveRecord model Language , with columns id and short_code (there are
So I have the following code, and I want to know which is considered
One certain tables I have an integer 'IsDeleted' field which defaults to 0. This
We have two websites for the same client (main www site and another for
Had a quick question.. Googled but nothing worthwhile found.. I have a simple type
I have been asked to create a website where the homepage consists of a
I have a class that uses linq to access the database. Some methods call

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.