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

  • Home
  • SEARCH
  • 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 8045889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:39:49+00:00 2026-06-05T05:39:49+00:00

Why is mysql using filesort when i order my selected rows with ORDER BY

  • 0

Why is mysql using filesort when i order my selected rows with ORDER BY x?

My table looks likes this:

CREATE TABLE `test` (
 `sdf` varchar(100) NOT NULL,
 `sdf33` varchar(100) NOT NULL,
 KEY `sdf_2` (`sdf`),
 FULLTEXT KEY `sdf33` (`sdf33`),
 FULLTEXT KEY `sdf` (`sdf`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

When running

EXPLAIN SELECT * 
FROM  `test` 
ORDER BY sdf

mysql says it’s using filesort, why? What do I need to change for it to not use filesort?

  • 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-05T05:39:51+00:00Added an answer on June 5, 2026 at 5:39 am

    The FULLTEXT index does not preseve ordering and can’t be used for ORDER BY.

    But even if you had a BTREE index on sdf, it most probably would not be used too, since it’s generally more expensive to to the table lookups in a loop than scan the table sequentially and sort it.

    The index would be of use for ORDER BY / LIMIT:

    CREATE INDEX ix_test_sdf ON test (sdf);
    
    SELECT  *
    FROM    test
    ORDER BY
            sdf
    LIMIT   10
    

    The LIMIT has a certain threshold after which the optimizer would prefer a filesort.

    You can force the optimizer to use the index:

    SELECT  *
    FROM    test FORCE INDEX (ix_test_sdf)
    ORDER BY
            sdf
    

    if you really don’t want to have a filesort.

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

Sidebar

Related Questions

I am trying to create a table in MySql using php. My code looks
I'm using three mysql tables that looks like: The table for members accounts |
The table looks like this: CREATE TABLE `tweet_tweet` ( `id` int(11) NOT NULL AUTO_INCREMENT,
Based on this question How to insert array into mysql using PDO and bindParam?
I've a simple MySQL table named 'test' with two columns: Auto incrementing int column
I'm trying to optimize this mysql query using EXPLAIN. Can somebody please help me
Database is MySQL with MyISAM engine. Table definition: CREATE TABLE IF NOT EXISTS matches
I have a large mysql table (about 5M rows) on which i frequently insert
All rows in MySQL tables are being inserted like this: 1 2 3 Is
I have two mysql tables: /* Table users */ CREATE TABLE IF NOT EXISTS

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.