Jump to content

Recommended Posts

My primary key is unique id numbers, but because of the nature of my php scripts, they get inserted out of order. I assume that this slows down queries, since the engine has to search the entire db to find a specific primary key. But if it was autoincremented, it would know exactly where to look... Right?

 

But my problem is that not every sequential number gets used... there's lots of gaps because the script will not re-use id numbers that belong to the data entries that get deleted before making it into the db.

 

So if I have lets say, 10 entries in the db, # 1-10, and then I need to add a new row at the end of the table whose id is 15... will mysql with autoincrementing turned on, create rows #11-14? Or do I have to do it myself?

 

If i have to do it myself, do I do a select on rows 11-14, to see if they exist yet? Or is there something more efficient?

thanks

But my problem is that not every sequential number gets used... there's lots of gaps because the script will not re-use id numbers that belong to the data entries that get deleted before making it into the db.

It's never supposed to re-use UIDs... and it never should... and neither should you.

 

You shouldn't be using these values for anything meaningful in your application -- if you are, you've made a mistake.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.