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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:40:44+00:00 2026-06-08T17:40:44+00:00

What are the general parameters for determining whether the key_len for a mysql index

  • 0

What are the general parameters for determining whether the key_len for a mysql index is ‘too long’?

For example, for longer VARCHAR columns, having a key would be longer. In one case I have an index with key_len=767. In which case should I do something like:

ADD INDEX (title(50));
  • 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-08T17:40:49+00:00Added an answer on June 8, 2026 at 5:40 pm

    If your table holds many rows and/or if you execute lots of SELECT ... ORDER BY queries, having index(es) on the field(s) involved will speed up the SELECT queries.
    However, it will slow down inserts, writes and updates on these fields, because the indexes need to be updated as well.
    Every index on a table uses disk space: if you’re really short on disk space, use a smaller key_len. But your queries will execute slower.

    Imagine a table with only one column, and only the first 3 characters are indexed. The table contains:
    Timo
    Timothée
    Tim
    Timothy
    Timmo

    SELECT * FROM `my_table` ORDER BY `name` ASC
    

    This query will use the index, but since its content is partially indexed, it will need extra processing to do a complete sort, and the execution will take longer.

    MySQL indexes can be up to 1000 bytes long (767 bytes for InnoDB tables). (link)

    The Innodb documentation says:
    In InnoDB, having a long PRIMARY KEY (either a single column with a lengthy value, or several columns that form a long composite value) wastes a lot of disk space. The primary key value for a row is duplicated in all the secondary index records that point to the same row. (See Section 14.3.11, “InnoDB Table and Index Structures”.) Create an AUTO_INCREMENT column as the primary key if your primary key is long, or index a prefix of a long VARCHAR column instead of the entire column.

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

Sidebar

Related Questions

I'm searching for a way to swap table columns around By some parameters (We
I am trying to make general purpose image display class which receives two parameters,
this is a fairly general question about whether people should be using brackets on
I'm very new to MSpec and BDD in general and are currently having trouble
In general, what is the maximum number of parameters a class constructor should accept?
I am rewriting this long INSERT statement and parameters used to look like this:
I have a general question on whether something can be done - and whether
General wisdom is when you remove a component from the stage you also need
General context : MVVM application. I have a View called JobView. Its DataContext is
General javascript question here, which would also be good to know how(if possible) to

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.