boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Autoindex (MySQL) help...

 
Post new topic   Reply to topic    boardom Forum Index -> PHP help
View previous topic :: View next topic  
Author Message
Anavy



Joined: 29 May 2002
Posts: 58

PostPosted: Tue Nov 26, 2002 2:49 pm    Post subject: Autoindex (MySQL) help... Reply with quote

I had to remove the last post from my Database (Ver 3.23.46). I did it from phpMyAdmin (ver 2.2.6) and removed the post from b2posts table.

Now, phpMyAdmin shows that the next Autoindex is 85 when it should be 84 (The ID of the post that was removed). Running OPTIMIZE_TABLE didn't fix the Autoindex value and I can't find a way to fix it manualy. Is there a simple way do do it?
Back to top
View user's profile Send private message
CodeWhacker



Joined: 31 Oct 2002
Posts: 12

PostPosted: Tue Nov 26, 2002 11:41 pm    Post subject: Reply with quote

Don't lose any sleep over it... just leave it as it is. No harm will come from having a hole in your set of post IDs. Anyone hitting that ID with a 'p=?' query string will just see an empty spot where the post would be.

If you're really all about having things perfectly sequential, export your tables to a file from phpMyAdmin, drop all the tables, massage the Post ID fields in the dump file by hand and re-import. Probably more bother than just leaving a hole, eh?
Back to top
View user's profile Send private message
Anavy



Joined: 29 May 2002
Posts: 58

PostPosted: Wed Nov 27, 2002 2:52 am    Post subject: Reply with quote

CodeWhacker, you are probably right about it. But I know that this value is kept somewhere and I wonder how to get there. It maybe a real issue someday.
Back to top
View user's profile Send private message
macshack



Joined: 17 Jul 2002
Posts: 1204
Location: Phoenix, Az

PostPosted: Wed Nov 27, 2002 6:04 am    Post subject: Reply with quote

Hi,

auto-increment is a special beast. It is MYSQL's way of guaranteeing that simultaneous inserts do not generate duplicate keys or id. Think about the issue of user A attempting to reset the auto-increment value while user B just did an insert an incremented it. Not good. This special 'feature' of MYSQL is managed by MYSQL only. Now I may be wrong here, but I do not know of any way to reset/set the value of the "next auto-increment" value to some value or to have MYSQL to internally reset it to a value it constructs. The only way I know to address this is the dump/drop/create/load steps talked about above.

I can not think of a condition where this concern of "holes" is an issue. You can always find out the value that was generated for your last insert and then potentially use that value in some other tuple of another table. In fact this would be the precise reason not to re-order things. Reverential keys would be all messed up.

So the bottom line here is don't worry about it. And if you do, make sure you understand the schema and the relationships.

michael e
Back to top
View user's profile Send private message Send e-mail
Anavy



Joined: 29 May 2002
Posts: 58

PostPosted: Wed Nov 27, 2002 6:50 am    Post subject: Reply with quote

Thanks Michael for the In-depth look into that matter.

Amir
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> PHP help All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group