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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:08:30+00:00 2026-05-23T11:08:30+00:00

MySQL appears to be not using indexes and is using filesort on the following

  • 0

MySQL appears to be not using indexes and is using filesort on the following query:

  SELECT `tweets`.* 
    FROM `tweets` 
   WHERE (`tweets`.contest_id = 159) 
ORDER BY tweet_id ASC, tweeted_at DESC LIMIT 100 OFFSET 0

I have indexes on contest_id, tweet_id and tweeted_at

When I execute EXPLAIN EXTENDED, Extra returns “Using where; using filesort”. How can I improve my query?

  • 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-23T11:08:30+00:00Added an answer on May 23, 2026 at 11:08 am

    When you mix ASC and DESC sorting, MySQL cannot use indexes to optimize the GROUP BY statement.

    Also, using multiple keys to sort will result in it not being able to optimize the query with indexes.

    From the docs:

    http://dev.mysql.com/doc/refman/5.6/en/order-by-optimization.html

    In some cases, MySQL cannot use
    indexes to resolve the ORDER BY,
    although it still uses indexes to find
    the rows that match the WHERE clause.
    These cases include the following:

    You use ORDER BY on different keys:

    SELECT * FROM t1 ORDER BY key1, key2;

    …

    You mix ASC and
    DESC:

    SELECT * FROM t1 ORDER BY key_part1
    DESC, key_part2 ASC;

    If the two columns you are ordering on are not part of the same key, then you are doing both of the above things.

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

Sidebar

Related Questions

Using MYSQL I would like to refactor the following SELECT statement to return the
How do I increase the maxPoolSize in Grails when using mysql? It appears to
mysql> select count(*) from table where relation_title='xxxxxxxxx'; +----------+ | count(*) | +----------+ | 1291958
Why does Mysql optimizer choose the secondary index when doing a 'select * from
Using standard mysql functions is there a way to write a query that will
I'd like to write the following as a MySQL SELECT statement to cut down
I have this mysql tables I want to display with jqgrid. The problem appears
MySQL ResultSets are by default retrieved completely from the server before any work can
I am using the Database Backup script by David Walsh( http://davidwalsh.name/backup-mysql-database-php ) to backup
I'm pulling content from a DB that has been sanitized using mysql_real_escape_string. Accordingly the

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.