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 
inserted.

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:
>   http://www.mysql.com/manual.php   (the manual)
>   http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <mysql-thread106988@stripped>
> To unsubscribe, e-mail 
> <mysql-unsubscribe-gerald_clark=suppliersystems.com@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


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