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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:24:08+00:00 2026-06-10T04:24:08+00:00

I am currently working on a project, which involves altering data stored in a

  • 0

I am currently working on a project, which involves altering data stored in a MYSQL database. Since the table that I am working on does not have a key, I add a key with the following command:

ALTER TABLE deCoupledData ADD COLUMN MY_KEY INT NOT NULL AUTO_INCREMENT KEY

Due to the fact that I want to group my records according to selected fields, I try to create an index for the table deCoupledData that consists of MY_KEY, along with the selected fields. For example, If I want to work with the fields STATED_F and NOT_STATED_F, I type:

ALTER TABLE deCoupledData ADD INDEX (MY_KEY, STATED_F, NOT_STATED_F)

The real issue is that the fields that I usually work with are more than 16, so MYSQL does not allow super-keys longer than 16 fields.
In conclusion, Is there another way to do this? Can I make (somehow) MYSQL to order the records according to the desired super-key (something like clustering)? I really need to make my script faster and the main overhead is that each group may contain records which are not stored on the same page of the disk, and I assume that my pc starts random I/Os in order to retrieve records.

Thank you for your time.
Nick Katsipoulakis

CREATE TABLE deCoupledData ( 
AA double NOT NULL DEFAULT '0', 
STATED_F double DEFAULT NULL, 
NOT_STATED_F double DEFAULT NULL, 
MIN_VALUES varchar(128) NOT NULL DEFAULT '-1,-1', 
MY_KEY int(11) NOT NULL AUTO_INCREMENT, 
PRIMARY KEY (MY_KEY), 
KEY AA (AA) ) 
ENGINE=InnoDB AUTO_INCREMENT=74358 DEFAULT CHARSET=latin1
  • 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-10T04:24:10+00:00Added an answer on June 10, 2026 at 4:24 am

    Okay, first of all, when you add an index over multiple columns and you don’t really use the first column, the index is useless.

    Example: You have a query like

    SELECT *
    FROM deCoupledData 
    WHERE
    stated_f = 5
    AND not_stated_f = 10
    

    and an index over (MY_KEY, STATED_F, NOT_STATED_F).

    The index can only be used, if you have another AND my_key = 1 or something in the WHERE clause.

    Imagine you want to look up every person in a telephone book with first name ‘John’. Then the knowledge that the book is sorted by last name is useless, you still have to look up every single name.

    Also, the primary key does not have to be a surrogate / artificial one. It’s nearly always better to have a primary key which is made up of columns which identify each row uniquely anyway.

    Also it’s not always good to have many indexes. Not only do indexes slow down INSERTs and UPDATEs, sometimes they just cause an extra lookup, since first a look at the index is taken and a second look to find the actual data.

    That’s just a few tips. Maybe Jordan’s hint is not a bad idea, “You should maybe post a new question that has your actual SQL query, table layout, and performance questions”.

    UPDATE:

    Yes, that is possible. According to manual

    If you define a PRIMARY KEY on your table, InnoDB uses it as the clustered index.

    which means that the data is practically sorted on disk, yes.

    Be aware that it’s also possible to define a primary key over multiple columns!

    Like

    CREATE TABLE deCoupledData ( 
    AA double NOT NULL DEFAULT '0', 
    STATED_F double DEFAULT NULL, 
    NOT_STATED_F double DEFAULT NULL, 
    MIN_VALUES varchar(128) NOT NULL DEFAULT '-1,-1', 
    MY_KEY int(11) NOT NULL AUTO_INCREMENT, 
    PRIMARY KEY (NOT_STATED_F, STATED_F, AA), 
    KEY AA (AA) ) 
    ENGINE=InnoDB AUTO_INCREMENT=74358 DEFAULT CHARSET=latin1
    

    as long as the combination of the columns is unique.

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

Sidebar

Related Questions

I'm currently working on a project that involves moving a database of documents for
I'm currently working on a re-platforming project, part of which involves a few dozen
I'm currently working on a project which involves multiple clients connected to a server
I'm currently working on a Java web project (Spring) which involves heavy use of
I am currently working on a PHP project which includes extensive database usage. The
I'm currently working on a project which involves optical character recognition in Android and
I am currently working on a fun project, which involves Ajax, HTML, JavaScript, PHP
The project that I'm currently working on involves translating a website that was written
Greetings, I'm currently working on a project which involves a login system which is
I am currently working on the WPF project which involves creating a touch-screen application

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.