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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:28:16+00:00 2026-06-15T08:28:16+00:00

I have created these two indexes based on how Index wizard suggested for different

  • 0

I have created these two indexes based on how Index wizard suggested for different scenarios.
I am wondering if they are the same or are they different?

Index (1):

CREATE NONClustered Index [IX_Rec_RecoveryDate_RecoveryDateTypeKey_CaseId] 
ON [Rec].[RecoveryDate] ([RecoveryDateTypeKey], [CurrentFlag])
INCLUDE (CaseId)

Index (2):

CREATE NONClustered Index [IX_Rec_RecoveryDate_currentFlag] 
ON [Rec].[RecoveryDate] ([CurrentFlag])
INCLUDE (CaseId, RecoveryDateTypekey)
  • 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-15T08:28:18+00:00Added an answer on June 15, 2026 at 8:28 am

    The question is, what queries are you trying to optimize?

    These two indexes are very different. The first index would be great for a query like this:

    SELECT CaseId 
    FROM Rec.RecoveryDate
    WHERE RecoveryTypeKey = 5
    AND CurrentFlag = 1 -- or whatever
    

    The first one indexes the columns in the WHERE clause. SQL Server would be able to search for the specified RecoveryDateTypeKey and CurrentFlag. Since the CaseId is INCLUDEd in the index leaf nodes, SQL Server would not have to join back to the table to get it.

    Using the same query, the second index would behave differently. If you are lucky, SQL Server would search for all records where CurrentFlag is 1. Then, it would traverse these leaf nodes looking for the matching RecoveryTypeKey. On the other hand, if there are a lot of records where the CurrentFlag is 1, SQL Server might choose to do an index scan instead.

    Then again, if you are wanting to optimize a query like this:

    SELECT CaseId, RecoveryTypeKey
    FROM Rec.RecoveryDate
    WHERE CurrentFlag = 1
    

    The first index would be useless, because the CurrentFlag is the second column in the index. SQL Server wouldn’t be able to search it for CurrentFlag = 1, so it would probably do an index scan.

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

Sidebar

Related Questions

I have created total 50 test scripts. All these scripts use almost same objects
Suppose I have two tables tab1, tab2. Full text indexes created on all varchar
I've got two PostgreSQL databases that have been created using the same sql file.
I have created a div there are two childs of that div one is
I am working on an application with many html pages. I have created these
Actually, in my app, I have created a graph using achartEngine . In these
I have a hashmap containing objects created via a constructor. These objects are in
I have a bunch of dynamically created *.BAT files. These BAT files are used
I have a txt file that created in notepad , containing these lines for
I have a form with multiple textboxes which are created dynamically, now all these

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.