SELECT LAST_INSERTID() very sloooow
Hi all, following query SELECT LAST_INSERT_ID() as auto_num FROM xrenders; fills our whole slow query log (500 kB a day). AUTO_INCREMENT field is int(11) type, primary key; table is of type MyISAM. We do the same operation on another similar table of the same db which is much larger without any performance problems. Affected table has 400.000+ records and mentioned query lasts tens or hunderds seconds. One record from the log: --- # Query_time: 223 Lock_time: 0 Rows_sent: 400633 Rows_examined: 400633 SET last_insert_id=400634; SELECT LAST_INSERT_ID() as auto_num FROM xrenders; --- This strange behavior appeared after upgrade from MySQL 3.23.32 to 3.23.47 on RedHat 6.2 There were never these problems before (many months). Affected table checked with CHECK .. EXTENDED passed OK. Any ideas? As I am not currently subscribed to this list, please reply to my e-mail as well. Thanks. -- MK - 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 [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: SELECT LAST_INSERTID() very sloooow
On Fri, Jan 25, 2002 at 02:22:12PM +0100, Marek Kustka wrote: following query SELECT LAST_INSERT_ID() as auto_num FROM xrenders; fills our whole slow query log (500 kB a day). Just do 'select last_insert_id() as auto_num'. The id isn't kept per table anyway, it is kept per session. Regards, Fred. -- Fred van Engen XO Communications B.V. email: [EMAIL PROTECTED] Televisieweg 2 tel: +31 36 5462400 1322 AC Almere fax: +31 36 5462424 The Netherlands - 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 [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: SELECT LAST_INSERTID() very sloooow
Fred van Engen wrote: On Fri, Jan 25, 2002 at 02:22:12PM +0100, Marek Kustka wrote: following query SELECT LAST_INSERT_ID() as auto_num FROM xrenders; fills our whole slow query log (500 kB a day). Just do 'select last_insert_id() as auto_num'. The id isn't kept per table anyway, it is kept per session. Regards, Fred. Oh, that was stupid bug. It was correct in the other case I mentioned. I haven't noticed the difference. The new server probably treated the statement differently than the previous one. Thanks much Fred! Virtual beer for you :) Marek -- MK - 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 [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php