All you need to do is : SELECT LAST_INSERT_ID();
The way it's written, you are doing the LAST_INSERT_ID() function call a number to times equal to the amount of rows in arp3_cam -----Original Message----- From: Anderson [mailto:[EMAIL PROTECTED] Sent: Sunday, March 21, 2004 6:37 PM To: [EMAIL PROTECTED] Subject: Slow Query Help Hello, I analize my mysql slow query log and see this: " # Time: 040320 15:35:31 # [EMAIL PROTECTED]: maxpcco_autoresp[maxpcco_autoresp] @ localhost [] # Query_time: 5 Lock_time: 0 Rows_sent: 764220 Rows_examined: 764220 SET last_insert_id=764597; SELECT LAST_INSERT_ID() AS id FROM arp3_cam; # [EMAIL PROTECTED]: maxpcco_autoresp[maxpcco_autoresp] @ localhost [] # Query_time: 5 Lock_time: 0 Rows_sent: 764222 Rows_examined: 764222 SET last_insert_id=764599; SELECT LAST_INSERT_ID() AS id FROM arp3_cam; # Time: 040320 15:35:33 # [EMAIL PROTECTED]: maxpcco_autoresp[maxpcco_autoresp] @ localhost [] # Query_time: 7 Lock_time: 0 Rows_sent: 764221 Rows_examined: 764221 SET last_insert_id=764598; SELECT LAST_INSERT_ID() AS id FROM arp3_cam; # Time: 040320 15:35:34 # [EMAIL PROTECTED]: maxpcco_autoresp[maxpcco_autoresp] @ localhost [] # Query_time: 6 Lock_time: 0 Rows_sent: 764224 Rows_examined: 764224 SET last_insert_id=764601; SELECT LAST_INSERT_ID() AS id FROM arp3_cam; # [EMAIL PROTECTED]: maxpcco_autoresp[maxpcco_autoresp] @ localhost [] # Query_time: 8 Lock_time: 0 Rows_sent: 764223 Rows_examined: 764223 SET last_insert_id=764600; SELECT LAST_INSERT_ID() AS id FROM arp3_cam; " Why these query are much slow to me? SET last_insert_id=(number); SELECT LAST_INSERT_ID() AS id FROM arp3_cam; Its necessary to examine all rows to get last id? Its possible to change anything to speed up this query? Thanks, Anderson Oliveira. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]