Jocelyn Fournier wrote:
>
> Hi,
>
> I wonder which of the following queries is faster :
>
> $result=mysql_query("SELECT lastauteur FROM forum ORDER BY date DESC LIMIT 1");
>
> or :
>
> $max=mysql_query("SELECT max(date) FROM forum");
> list($max)=mysql_fetch_row($max);
> $result=mysql_query("SELECT lastauteur FROM forum WHERE date='max'");
>
> (column date is declare as datetime, and is a non unique index)
I'd bet the all-in-one solution behind door #1.
SELECT lastauteur FROM forum ORDER BY date DESC LIMIT 1 # very elegant
If not, I'd use explain on the select to see whether it's picking
up your index on date. When it comes down to it, doing your own benchmark
of each method will always be better than what anyone might think.
--Josh
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks >> free web link monitoring Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
---------------------------------------------------------------------
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