I found it interesting.   Thanks Eric.

>>(reconstructed from archives i accidentally deleted the copy in my mailbox
>>>Daniel Clark writes:
>>>I don't see how LIMIT would make a difference.   LAST_INSERT_ID() only 
>>>returns one record.
>>>But it's worth trying in a big loop to get timing numbers.
>>
>>Well, I decided to test this all out and see what happened. From what my 
>>little test was able to determine, there is no difference in speed from 
>>doing:
>>
>>SELECT LAST_INSERT_ID();  vs SELECT LAST_INSERT_ID() LIMIT 1;
>>
>>I used 100,000 selects as my benchmark number (which on my box here took 
>>about 40 seconds per run to complete).  Times were measured using unix time, 
>>and I averaged the user times and the difference was so small as to be 
>>negligable, then i decided to measure the same thing but with
>>SELECT LAST_INSERT_ID() FROM table; and it was approximately 25% slower (but 
>>im assuming as the table grew in length so would the gap in speed.
>>
>>Conclusion: it makes no difference positive or negative including the LIMIT, 
>>but as Michael pointed out including the FROM clause causes a big penalty.  
>>I hope someone else finds this slightly interesting. For completeness im 
>>including the program i wrote to test this. Your mileage may vary, it needs 
>>a little configuring for your particular setup before you can run tests. 
>>(database name, user/password etc) you have to manually change the one line 
>>inside the loop to call whichever function you want to test. And its also 
>>handy to change the one print statement before the loop.
>>
>>Eric




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to