List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:August 12 1999 7:23pm
Subject:Re: Use (problem with?) LIMIT in select statement
View as plain text  
Paul DuBois wrote:
> 
> At 8:31 PM +0200 8/11/99, Christian Mack wrote:
> >tonu-mysql@stripped wrote:
> >>
> >> On Wed, 11 Aug 1999, Paul McAvoy wrote:
> >>
> >> > Hi, I am currently using Mysql 3.22.25-1 (RPM).  I think that I
> >>may have found
> >> > a bug, or it may be that I am unclear on how the select statement
> works.
> >> >
> >> > My Query is similar to this:
> >> >
> >> > SELECT id,name FROM list ORDER BY name LIMIT 20;
> >> >
> >> > I was under the impression that teh LIMIT clause was used to limit the
> >> > return set.
> >>
> >>   Yes, it must work like you understood. It must order all items in your
> >> table and THEN take the first 20 records and give them back. If it does
> >> something different, then it's wrong.
> >>
> >>     Tonu
> >
> >Hi
> >
> >Mysql doesn't do this.
> >As described in the manual mysql will stop getting results, when it
> >reached the given amount.
> >It will only satisfy the WHERE part of your query.
> >The ordering is done after getting the results.
> >So you get with the above SELECT 20 rows which are ordered, not the
> >first 20 from the ordered list.
> 
> ?
> 
> Are you sure about that?  I thought that LIMIT was something like
> HAVING in that
> it post-processes the result set after having determined what the result set
> was.
> 
> If that's not so, then why does a LIMIT 20 query on a table with a zillion rows
> take longer than on a table with a few rows?
> 
> --
> Paul DuBois, paul@stripped

Hi ALL

My apologies.
I was absolutely wrong :(

Mysql is using the ORDER BY part before limiting the results.

Obviously I had an black out.

Sorry
Christian

Thread
Use (problem with?) LIMIT in select statementPaul McAvoy11 Aug
  • Re: Use (problem with?) LIMIT in select statementtonu-mysql11 Aug
    • Re: Use (problem with?) LIMIT in select statementChristian Mack11 Aug
      • Re: Use (problem with?) LIMIT in select statementtonu-mysql11 Aug
        • Re: Use (problem with?) LIMIT in select statementSteve Edberg11 Aug
        • Re: Use (problem with?) LIMIT in select statementTonu Samuel11 Aug
      • Re: Use (problem with?) LIMIT in select statementSteve Ruby11 Aug
      • Re: Use (problem with?) LIMIT in select statementThimble Smith11 Aug
        • Re: Use (problem with?) LIMIT in select statementPaul McAvoy11 Aug
      • Re: Use (problem with?) LIMIT in select statementPaul McAvoy11 Aug
      • Re: Use (problem with?) LIMIT in select statementPaul DuBois11 Aug
    • Re: Use (problem with?) LIMIT in select statementChristian Mack12 Aug
RE: Use (problem with?) LIMIT in select statementClinton11 Aug