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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:32:51+00:00 2026-06-09T00:32:51+00:00

In one MySQL database table, I have the following index: type: BTREE unique: no

  • 0

In one MySQL database table, I have the following index:

  • type: BTREE
  • unique: no
  • packed: no
  • fields: lastname, firstname, age

When I do a query like this …

SELECT firstname, lastname FROM table ORDER BY lastname ASC, firstname ASC, age DESC

… MySQL doesn’t use the index.

But when I use “age” in ascending order as well, it does:

SELECT firstname, lastname FROM table ORDER BY lastname ASC, firstname ASC, age ASC

Why is this so? Are columns always indexed for ascending-order only? Or can I use them all in descending order as well? Why can’t I use mixed orders?

Thanks in advance!

  • 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-09T00:32:52+00:00Added an answer on June 9, 2026 at 12:32 am

    At this time (MySQL 5.6 and less) indexes are all implemented in ascending order.

    If you mix the order (ASC vs DESC) in the ORDER clause, the index cannot be used beyond the point where the order changes.

    If you specify all ASC, the index can be utilized fully, and if you specify all DESC, it can still be utilized fully, only MySQL will traverse the index backwards.

    You could add another column that has the inverse age (max_age – age), and index on that instead, so that you can use ASC for all of the columns.

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

Sidebar

Related Questions

i have a large mysql database table in which one column contains values ranging
I have a calendar table in my MYSQL database with one field named datefield
In a MySQL database I have two tables linked in a join. One table
What I have is two tables inside of a mysql database. One table contains
I have one field in database table with following lines show_email_icon= show_hits= feed_summary= page_title=
I have only one table in my mySql database for a very basic website
I have a MySQL database-table with the following colums ID status (can contain values
I have a mysql database which have set of tables One table have a
I have the following table in a MySql database: **EmpInfo** ID Name Address --------------------------------------------------------
I have the following mysql table schema: SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; -- -- Database: `network` --

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.