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 from the properties table. There
is about 500,000 rows in the properties table.

This is a costly query:
+----+-------------+------------+-------+---------------+---------+---------+------+-------+-----------------------------------------------------------+
| id | select_type | table      | type  | possible_keys | key     |
key_len | ref  | rows  | Extra
            |
+----+-------------+------------+-------+---------------+---------+---------+------+-------+-----------------------------------------------------------+
|  1 | SIMPLE      | properties | range | Country       | Country | 7
     | NULL | 74602 | Using where; Using index; Using temporary; Using
filesort |
+----+-------------+------------+-------+---------------+---------+---------+------+-------+-----------------------------------------------------------+
1 row in set (0.00 sec)

Any ideas on how to get rid of the "Using temporary; Using filesort"
or do this in a better way with PHP?

Thanks!
Michael

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

Reply via email to