Re: Optimizing GROUP BY and ORDER BY

2008-07-25 Thread Michael Stearne
On Fri, Jul 25, 2008 at 12:35 PM, Arthur Fuller <[EMAIL PROTECTED]> wrote: > ORDER BY implies a sort of the result set. I don't think there is any way > around that. I guess so. What I am doing is to just run the query once per day and store the results in memcache. Michael > > Arthur > > On Fr

Re: Optimizing GROUP BY and ORDER BY

2008-07-25 Thread Rob Wultsch
On Fri, Jul 25, 2008 at 12:27 AM, Michael Stearne <[EMAIL PROTECTED]> wrote: > I have a query: > > SELECT Country, COUNT( Country ) AS Cnt > FROM properties WHERE ( > Country != 'USA' AND > Country != 'US' AND > Country != 'Unit' AND > Country != 'United States' > AND

Optimizing GROUP BY and ORDER BY

2008-07-25 Thread Michael Stearne
I have a query: SELECT Country, COUNT( Country ) AS Cnt FROM properties WHERE ( Country != 'USA' AND Country != 'US' AND Country != 'Unit' AND Country != 'United States' AND Country != ' ' AND Country IS NOT NULL ) GROUP BY Country ORDER BY Cnt DESC LIMIT 8 that gets the top 8 non-US countries fr