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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:30:28+00:00 2026-05-11T10:30:28+00:00

I’m wondering if MySQL takes collation into account when generating an index, or if

  • 0

I’m wondering if MySQL takes collation into account when generating an index, or if the index is generated the same regardless of collation, the collation only being taken into account when later traversing that index.

For my purposes, I’d like to use the collation utf8_unicode_ci on a field. I know this particular collation has a relatively high performance penalty, but it’s still important to me to use it.

I have an index on that field which is being used to satisfy an ORDER BY clause, retrieving the rows in order quickly (avoiding a filesort). However, I’m not sure whether using this collation is going to affect the speed of rows as they are read back from the index, or if the index stores data in an already-normalised state according to that collation, allowing for the performance penalty to be entirely in generating the index and not reading it back.

  • 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-11T10:30:29+00:00Added an answer on May 11, 2026 at 10:30 am

    I believe that the btree structure will be different because it has to compare the column values differently.

    Look at these two query plans:

    mysql> explain select * from sometable where keycol = '3'; +----+-------------+-------+------+---------------+---------+---------+-------+------+--------------------------+ | id | select_type | table | type | possible_keys | key     | key_len | ref   | rows | Extra                    | +----+-------------+-------+------+---------------+---------+---------+-------+------+--------------------------+ |  1 | SIMPLE      | pro   | ref  | PRIMARY       | PRIMARY | 66      | const |   34 | Using where; Using index |  +----+-------------+-------+------+---------------+---------+---------+-------+------+--------------------------+   mysql> explain select * from sometable where binary keycol = '3'; +----+-------------+-------+-------+---------------+---------+---------+------+-------+--------------------------+ | id | select_type | table | type  | possible_keys | key     | key_len | ref  | rows  | Extra                    | +----+-------------+-------+-------+---------------+---------+---------+------+-------+--------------------------+ |  1 | SIMPLE      | pro   | index | NULL          | PRIMARY | 132     | NULL | 14417 | Using where; Using index |  +----+-------------+-------+-------+---------------+---------+---------+------+-------+--------------------------+ 

    If we change the collation for the comparison, suddenly it isn’t even able to seek the index anymore and has to scan every row. The actual values stored in the index will be the same regardless of collation, for instance, because it will still return the value in its original casing regardless of whether it’s using a case sensitive or case insensitive collation.

    So lookups against a case insensitive collation should be a little less efficient.

    However, I doubt you’d ever be able to notice the difference; note that MySQL makes everything case insensitive by default, so the impact can’t be that terrible.

    UPDATE:

    You can see a similar effect for order by operations:

    mysql> explain select * from sometable order by keycol collate latin1_general_cs; +----+-------------+-------+-------+---------------+---------+---------+------+-------+-----------------------------+ | id | select_type | table | type  | possible_keys | key     | key_len | ref  | rows  | Extra                       | +----+-------------+-------+-------+---------------+---------+---------+------+-------+-----------------------------+ |  1 | SIMPLE      | pro   | index | NULL          | PRIMARY | 132     | NULL | 14417 | Using index; Using filesort |  +----+-------------+-------+-------+---------------+---------+---------+------+-------+-----------------------------+  mysql> explain select * from sometable order by keycol ; +----+-------------+-------+-------+---------------+---------+---------+------+-------+-------------+ | id | select_type | table | type  | possible_keys | key     | key_len | ref  | rows  | Extra       | +----+-------------+-------+-------+---------------+---------+---------+------+-------+-------------+ |  1 | SIMPLE      | pro   | index | NULL          | PRIMARY | 132     | NULL | 14417 | Using index |  +----+-------------+-------+-------+---------------+---------+---------+------+-------+-------------+ 

    Note the extra ‘filesort’ stage required to execute the query. That means mysql is queuing up the result in a temporary buffer and sorting it itself using a quicksort in an extra stage, throwing out whatever the index order was. Using the original collation this step is uneccessary as mysql knows the order from index initially.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

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.