List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 20 2002 2:01pm
Subject:Re: last_insert_id questions
View as plain text  
At 1:49 -0700 9/20/02, PR wrote:
>I have a message board app I'm using where I'm trying to make the code
>faster and more efficient than it is now.  At times this board will
>generate a lot of new posts to it very very quickly.  In one section where
>posts are added, after the post is made and inserted into mysql, we need to
>get the post number, which is an auto-increment field, for the insert just
>finished.  And then we need to use this to update the boards table with
>stuff like last post and then maybe send an email with a link in it, etc..
>I found the last_insert_id section and it looks like this is what I want,
>where after I do the insert, I can do something like
>mysql> SELECT LAST_INSERT_ID();
>
>My questions are:
>
>If I have something like 500 concurrent users is this a safe and reliable
>way to get that info if 50 of them are posting at the same time?

Yes.  It does what you want.

>
>Is there anything that would prevent the select from getting the last id
>that I need to watch for such as finish statements, etc...

What's a "finish statement"?

>
>What version did this feature start in so I can make sure we can use it.

Way, way, back.  There's no chance that your version of MySQL doesn't
support it.

More specifically, 3.21.11. :-)

>
>Thanks in advance for any assistance.

Thread
last_insert_id questionsPR20 Sep
  • Re: last_insert_id questionsPaul DuBois20 Sep
  • what is thread cache ?cristian ditoiu22 Sep
    • Re: what is thread cache ?Michael Bacarella22 Sep