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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:12:26+00:00 2026-05-27T05:12:26+00:00

I have a table with two specific columns, one is auto-incremented number, the other

  • 0

I have a table with two specific columns, one is auto-incremented number, the other is a custom number. These two columns will be fetched together in the where condition frequently. Now I have 2 choices with InnoDB engine:

  1. Use the auto-incremented number as the primary key, while create an index on the custom number column. this choice will be very quickly on inserting because the new record will be inserted one by one althoug it will cause some merge or split on the clustered index. But it will take extra time and space to construct the index on the custom number column.

  2. I can use the auto-incremented number and the custom number column together as the primary key. On inserting, the record will not be placed one after another, so it will cause frequent B Tree primary index split and merge.

These two choice will both speed the query which use the auto-incremented number and custom number column as filter condition. But if we consider the insertion and space, which one would be prefered?

Thanks very much!

  • 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-27T05:12:26+00:00Added an answer on May 27, 2026 at 5:12 am

    The composite primary key seems to be better in this case, since the key becomes a coverage index. And why do you think it will require splits? The autoincremented field has to be the first in the composite primary key in InnoDB, that is all new rows will be appended to the end.

    And an autoincremented field in InnoDB is unique across the table even in a composite primary key, as opposed to that in MyIsam where it restarts for each new rest part of the primary key.

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

Sidebar

Related Questions

I have a table with two columns and one row, and 100% width across
I have two tables that have identical columns. One table houses imported data, the
I have a table and two databases which have the same table, but one
I have a table with two columns: column A column B 1 2 1
I have a table with two columns, GroupId and ParentId (both are GUIDS). The
I have large table. consisting of only 3 columns (id(INT),bookmarkID(INT),tagID(INT)).I have two BTREE indexes
I have two tables, one is a list of songs. The other is a
I have two tables, one a schedule the other a list of available appointments
I have a table ABR with three columns: two lookup values, A and B
I have two tables, each with three boolean (ms-access Yes/No) columns. Table 1: A1,

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.