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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:55:43+00:00 2026-05-28T01:55:43+00:00

I have a table with around 19 columns which contains reasonable large amount of

  • 0

I have a table with around 19 columns which contains reasonable large amount of data and is primarily being queried to retrieve data using select statements based on different where clause. Since this table is primarily queried to get data, I thought about creating Non Clustered indexes based on the different where clauses getting used in the queries. Also, all the get queries returns all the columns in the table as part of the select list. Based on the information above, I have two questions for selecting the indexes:

  1. let us assume that we have the following SPs which queries as:

    where [col_a] = {value} and [col_b] = {value}
    
          [col_b] = {value} and [col_a] = {value}
    
          [col_a] = {value} and [col_c] = {value} and [col_d] = {value}
    
          [col_a] = {value} and [col_c] = {value}
    

    I have created the following Non Clustered indexes on the table as

    [col_a] and [col_b] –> Would the first SP still use this index as the
    orders are reversed

    [col_a] and [col_c] and [col_d] –> Would the last SP use this index
    as the first two columns match with order

    Also, should we go ahead and try to define Non Clustered indexes based on the filter/join clauses for the get SPs on a table?

  2. Since the select list in all the SPs return the entire list of columns, I added all the columns of the table as included columns in the Non Clustered indexes(covering index) to avoid bookmark lookups. Is this approach correct? What are the space implications in this case since we are storing all the table columns as part of the index definition?

  • 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-28T01:55:43+00:00Added an answer on May 28, 2026 at 1:55 am

    [col_a] and [col_b]
    Would the first SP still use this index as
    the orders are reversed

    Yes – if you specify both columns, and your index contains those two columns as the first two in its list of columns, then the index can be used, and the order is not important.

    If you have an index (col_a, col_b), it can be used if you specify:

    • just col_a
    • both col_a and col_b (order is irrelevant)

    but it cannot be used for a query that specifies just col_b (but not col_a). In order to be considered for use, the n left-most columns (n >= 1) must be used/defined – in any order.

    [col_a] and [col_c] and [col_d]
    Would the last SP use this index
    as the first two columns match with order

    Yes – as I mentioned above, if the n left-most columns are used, the index can be considered, so if your specify the first two of a total of three – you’re fine.

    Word of warning: just because you specify the right columns doesn’t necessarily mean that index will actually be used in the end. The query optimizer will consider it for use – but it might still go another way if that’s more convenient / faster.

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

Sidebar

Related Questions

I have a really large table (around 32 columns and 1000+ rows) which I'm
I have a table with around 15 columns which can be queried with different
I have a table in Excel which has the columns: Date Person Name Amount
I have table rows of data in html being filled from a CGI application.
I have a log table that contains job status. One of the columns is
I am using a simple table with 6 columns, 3 of which are of
I have a table of time-series data of which I need to find all
I have a table with around 15 columns. What I would like to be
I have a query which I'm trying to group multiple table columns as text,
we have a database table which has around 200,000 records. which includes 3 ntext

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.