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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:44:54+00:00 2026-05-11T12:44:54+00:00

When you create an index on a column or number of columns in MS

  • 0

When you create an index on a column or number of columns in MS SQL Server (I’m using version 2005), you can specify that the index on each column be either ascending or descending. I’m having a hard time understanding why this choice is even here. Using binary sort techniques, wouldn’t a lookup be just as fast either way? What difference does it make which order I choose?

  • 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. 2026-05-11T12:44:55+00:00Added an answer on May 11, 2026 at 12:44 pm

    This primarily matters when used with composite indexes:

    CREATE INDEX ix_index ON mytable (col1, col2 DESC); 

    can be used for either:

    SELECT  * FROM    mytable ORDER BY         col1, col2 DESC 

    or:

    SELECT  * FROM    mytable ORDER BY         col1 DESC, col2 

    , but not for:

    SELECT  * FROM    mytable ORDER BY         col1, col2 

    An index on a single column can be efficiently used for sorting in both ways.

    See the article in my blog for details:

    • Descending indexes

    Update:

    In fact, this can matter even for a single column index, though it’s not so obvious.

    Imagine an index on a column of a clustered table:

    CREATE TABLE mytable (        pk INT NOT NULL PRIMARY KEY,        col1 INT NOT NULL ) CREATE INDEX ix_mytable_col1 ON mytable (col1) 

    The index on col1 keeps ordered values of col1 along with the references to rows.

    Since the table is clustered, the references to rows are actually the values of the pk. They are also ordered within each value of col1.

    This means that that leaves of the index are actually ordered on (col1, pk), and this query:

    SELECT  col1, pk FROM    mytable ORDER BY         col1, pk 

    needs no sorting.

    If we create the index as following:

    CREATE INDEX ix_mytable_col1_desc ON mytable (col1 DESC) 

    , then the values of col1 will be sorted descending, but the values of pk within each value of col1 will be sorted ascending.

    This means that the following query:

    SELECT  col1, pk FROM    mytable ORDER BY         col1, pk DESC 

    can be served by ix_mytable_col1_desc but not by ix_mytable_col1.

    In other words, the columns that constitute a CLUSTERED INDEX on any table are always the trailing columns of any other index on that table.

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

Sidebar

Related Questions

i have a char(10) column in a table in a SQL-Server 2005 database: CREATE
Is it possible to create an index that has as one of its columns
I'm using this SQL query to create an index: $query = CREATE INDEX id_index2
If I have a table column with data and create an index on this
Suppose I created index with descending order CREATE INDEX `MyTable.MyIndex` USING BTREE ON `MyTable`
I want to create an index page with a couple of results for each
Can someone help me create an index/count button for a UITableView, like this one?
Using SQL Server, I'm trying to query a kind of averaged count from a
I have a SQL Server 2005 database with several tables. One of the tables
I'm using SQL Server 2K8 and have a table used solely to generate ids

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.