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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:52:11+00:00 2026-05-16T09:52:11+00:00

A quick question. I have a simple table with this structure: USERS_TABLE = {id},

  • 0

A quick question. I have a simple table with this structure:

USERS_TABLE = {id}, name, number_field_1, number_field_2, number_field_3, number_field_4, number_field_5

Sorting is a major feature, one field at a time at the moment. Table can have up to 50 million records. Most selects are done using the “id” field, which is the primary key and it’s indexed.

A sample query:

SELECT * FROM USERS_TABLE WHERE id=10 ORDER BY number_field_1 DESC LIMIT 100;

The question:

Do I create separate indexes for each “number_field_*” to optimize ORDER BY statements, or is there a better way to optimize? Thanks

  • 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-16T09:52:12+00:00Added an answer on May 16, 2026 at 9:52 am

    There’s no silver bullet here, you will have to test this for your data and your queries.

    If all your queries (e.g. WHERE id=10) returns few rows, it might not be worth indexing the order by columns. On the other hand, if they return a lot of rows, it might help greatly.

    If you always order by atleast one of the fields, consider creating an index on that column, or a compound index on some of these columns – keep in mind that if you have a compound index on (num_field_1,num_field_2) and you order only by num_field_2 , that index will not be used. You have to include the leftmost fields of the index to make use of it.

    On the other hand, you seem to have a lot of different fields you order by, the drawback of creating an index on each an every one of them is your indexes will be much larger, and your inserts/deletes/updates might start to get slower.

    Basically – there is no shortcut. You’ll have to play around with which indexes works best for your queries and tune accordingly, while carefully analyzing your queries with EXPLAIN

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

Sidebar

Related Questions

just a quick question. I've got this table in a Word template which have
A quick simple regex question I have a domain name in a string that
A quick question in between: I have a simple WeakRunnableList. Is this way ok
A quick and simple question:). I have a .jar with allot of classes and
Question simple and quick: I have started to use Netbeans to write some code
Quick question, I have a simple javascript problem that I don't know the fix
Quick question, again, I'm sure this is ridiculously simple but I don't see what
Alright so a quick SQL question here(using sql-server-2008). I have a mapping table names
I have a quick (hopefully simple) question. I have some information stored in a
I have a simple question here. I need to UPDATE a row table by

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.