List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:April 24 2002 7:24pm
Subject:Re: last_insert_id() query
View as plain text  
Don't  include a from clause with the last_insert_id(), or you will get 
a full table scan.

The last_insert_id will only give you the insert id for the last record 

mysql mailing list user wrote:

> Hi,
> I have a big problem with last_insert_id() query.
> I am adding records to a table with about half a million records in 
> it. The
> insert takes well under a second. I then call last_insert_id as I need to
> make a link to another table.
> The last_insert_id takes around 2 minutes!!! Yes *minutes*!
> Has anybody any idea what might be going wrong here. The auto increment
> field is definitely a primary key and any other searches on the table are
> quite quick.
> Cheers
> ---------------------------------------------------------------------
> Before posting, please check:
>   (the manual)
>           (the list archive)
> To request this thread, e-mail <mysql-thread106988@stripped>
> To unsubscribe, e-mail 
> <>
> Trouble unsubscribing? Try:

last_insert_id() querymysql mailing list user24 Apr
  • Re: last_insert_id() queryGerald Clark24 Apr