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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:57:10+00:00 2026-05-22T20:57:10+00:00

I’m working with a contract developer who is starting to create tables (MySQL) without

  • 0

I’m working with a contract developer who is starting to create tables (MySQL) without define a Primary Key. Instead, he is defining a column with a UNIQUE constraint with an AUTO_INCREMENT. I’ve never seen this done before, so I wanted to understand the implications of defining tables this way. One downside would be not being able to create foreign keys if needed. What are some other implications, good or bad, of creating tables this way. Maybe I’m missing a concept here…

  • 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-22T20:57:11+00:00Added an answer on May 22, 2026 at 8:57 pm

    Defining MySQL without explicit primary keys is a very very bad idea.
    If a PK is missing, MySQL will create an implicit (but very real) integer autoincrementing primary key.
    This PK will be included in every secondary key in InnoDB and will determine your primary sort order in MyISAM.

    Consequence
    You have just slowed down the performance of every select, insert and update.
    For no purpose what so ever.

    InnoDB: extra lookup required to get to table data
    In InnoDB an extra lookup needs to be done, because all secondary indexes refer to the PK and not to the rows themselves.

    MyISAM: wasted space
    In MyISAM the penalty is not that great, but you’re still dragging along a 4 byte unused field that doesn’t get used.

    InnoDB + MyISAM: Useless generation of autoincrement field
    Because an implicit autoincrementing PK gets created, and you also needed a extra autoincrementing key to do joins; In order to prevent duplicate autoincrement fields, you now have not 1, but 2 table locks per insert.

    InnoDB: with joins the lookup probem mentioned above doubles
    If you do a join using a field that’s not the PK, InnoDB needs to do an extra lookup per join to get to the records of that other table.

    InnoDB: worst of all you lose the benefit of covering indexes
    You have disabled one of the best optimizations in InnoDB, covering indexes.
    If MySQL can resolve the query using only the data in the indexes, it will never read the table, this will result in a significant speed gain. Now that 50% of every index in InnoDB is unused space you have just nixed your chances of that optimization being used.

    Please beat this contractor with a clue stick!
    enter image description here

    Links:
    http://www.xaprb.com/blog/2006/07/04/how-to-exploit-mysql-index-optimizations/ (slow link, but recommend reading).
    O’Reilly on InnoDB’s covering indexes
    http://tag1consulting.com/MySQL_Engines_MyISAM_vs_InnoDB

    BTW, if your contractor says, it does’t matter much because he’s using MyISAM, beat him again, you should always use InnoDB unless you have a good reason not too.
    InnoDB is much much safer in production, MyISAM has its uses but gets corrupted too easily.

    • 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
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.