auto_incremenent special functionality
Moderator: General Moderators
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
auto_incremenent special functionality
Is there a way for an auto_increment to check the LOWEST available id? We have an items table which stores hundreds of thousands of records, but users drop items a LOT, so there are TONS of unused ids, even though the ids are getting huge..
Thanks!
Thanks!
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
Table contains 2,106,403 rows. The current id is 548,772,067. Just seems like a waste.Oren wrote:We've talked about this before... use the search. But seriously, you don't really need it, auto_increment should be good enough for whatever it is that you are doing.
Also, my search for "auto_increment" brought up scarcely anything related to what I was asking.. sorry for posting in the forum.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Think about this logically... auto_increment. What does that imply? That the field will increment itself as the data grows. The fact that there are gaps in your numbering sequence of your IDs means nothing. Nor should it. The ID field, at the data level, is merely an identifier of the row.
Yes, it can be used as an index for searching (and in fact it probably should), but the gaps in the sequences mean nothing.
As for searching, you may also try searching for the term 'identity column' which is a term used often by the likes of Oracle, Sybase and MS SQL Server to describe a primary key, auto incrementing field.
Yes, it can be used as an index for searching (and in fact it probably should), but the gaps in the sequences mean nothing.
As for searching, you may also try searching for the term 'identity column' which is a term used often by the likes of Oracle, Sybase and MS SQL Server to describe a primary key, auto incrementing field.
- ReverendDexter
- Forum Contributor
- Posts: 193
- Joined: Tue May 29, 2007 1:26 pm
- Location: Chico, CA
I may be trying to put out a fire with gasoline, but what if it isn't good enough? I'd be interested in an answer to this just from an acedemic standpoint.Oren wrote:We've talked about this before... use the search. But seriously, you don't really need it, auto_increment should be good enough for whatever it is that you are doing.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- ReverendDexter
- Forum Contributor
- Posts: 193
- Joined: Tue May 29, 2007 1:26 pm
- Location: Chico, CA
As everah and others have said (over and over again), it doesn't make any difference, as long as the numbers are unique! If you start playing games with auto_increment, you risk screwing up your database by inadvertently creating a duplicate key. Some people always want to use elements for purposes other than for which they are intended. That's not a good idea.