Jump to content

clear out empty registry between ID's


criostage

Recommended Posts

Hi, i know this ain tan "BIG" question but ever since i started to play with php and mysql i noticed this. while testing values etc ... every time i delete an registry and re-add it later the id (as auto incremental) will add the registry normaly but will leave an "blank" id between 2 entries for example:

 

id  name     profession
1   john      programmer
2   mario    plummer
5   Samus  Bounty Hunter

 

Is there anyway to fill up the gaps or remove them? are these gaps "harmfull" to the database search's? thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/247515-clear-out-empty-registry-between-ids/
Share on other sites

These gaps are not harmfull, they are there for a good reason.  Auto_Inc is normaly only used for indexed keys.  As such the number is relative to an indexed postion within the table.  Each new row added to the table will get an indexed postion after the last row that was added, even if there have been other rows that have been deleted in between times.  The database is perfectly happy with these missing rows, otherwise I imagine you would be forced to re-index every time deleted a row.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.