List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:September 6 2001 6:00am
Subject:ORDER BY ... DESC LIMIT 1 optimization ?
View as plain text  
Hi!

>>>>> "Fournier" == Fournier Jocelyn <Fournier> writes:

Fournier> Hi,
Fournier> Won't it be possible the MySQL parser optimize the SELECT y FROM x ORDER BY
Fournier> z DESC LIMIT 1 as :

Fournier> SELECT MAX(z) FROM x;
Fournier> followed by :
Fournier> SELECT y FROM x WHERE z=a;

Fournier> (where 'a' is the result of the first SELECT MAX(z) query)

Yes this is possible;  MySQL 4.0 already does this.

<cut>

Regards,
Monty

Thread
ORDER BY ... DESC LIMIT 1 optimization ?Fournier Jocelyn [Presence-PC]5 Sep
  • Re: ORDER BY ... DESC LIMIT 1 optimization ?Timothy Smith6 Sep
  • Re: ORDER BY ... DESC LIMIT 1 optimization ?Fournier Jocelyn [Presence-PC]6 Sep
  • Re: ORDER BY ... DESC LIMIT 1 optimization ?Fournier Jocelyn [Presence-PC]6 Sep
  • ORDER BY ... DESC LIMIT 1 optimization ?Michael Widenius6 Sep
  • Re: ORDER BY ... DESC LIMIT 1 optimization ?Paul Cadach6 Sep
  • Re: ORDER BY ... DESC LIMIT 1 optimization ?Fournier Jocelyn [Presence-PC]6 Sep
  • Re: ORDER BY ... DESC LIMIT 1 optimization ?Paul Cadach6 Sep
  • Re: ORDER BY ... DESC LIMIT 1 optimization ?Fournier Jocelyn [Presence-PC]6 Sep
    • Re: ORDER BY ... DESC LIMIT 1 optimization ?Timothy Smith6 Sep
      • Re: ORDER BY ... DESC LIMIT 1 optimization ?Michael Widenius6 Sep
      • Re: ORDER BY ... DESC LIMIT 1 optimization ?Michael Widenius16 Jan
  • Re: ORDER BY ... DESC LIMIT 1 optimization ?Paul Cadach6 Sep