Pretty straightforward. The other query is identical, except that the column is of type INT. It executes a little faster, as would problably be expected.

SELECT DISTINCT directory
FROM pagestats
ORDER BY directory

+-----------+-------+---------------+-----------+---------+--------+
| table     | type  | possible_keys | key       | key_len | ref    |
+-----------+-------+---------------+-----------+---------+--------+
| pagestats | index | [NULL]        | Directory |      25 | [NULL] |
+-----------+-------+---------------+-----------+---------+--------+
--------+-------------+
rows   | Extra       |
--------+-------------+
438710 | Using index |
--------+-------------+


----- Original Message ----- From: "Michael Stassen" <[EMAIL PROTECTED]>
To: "Jim McAtee" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, November 16, 2004 10:03 PM
Subject: Re: Speed up SELECT DISTINCT



It is difficult to say without knowing more. It would be helpful if you'd show us the queries, as well as what EXPLAIN <http://dev.mysql.com/doc/mysql/en/EXPLAIN.html> has to say about them. Your table structure may also help.

I will say that most queries I've seen posted here which used DISTINCT could have been written more efficiently without DISTINCT. Without seeing your queries though, I'd be foolish to speculate.

Michael

Jim McAtee wrote:
I have a web application using MySQL 3.2x server. In the application theres an HTML form used for searching an ISAM table of about 500k records. To populate select (drop down) fields in the form I do a couple of SELECT DISTINCT queries against this table.

What's the best indexing strategy to speed up these queries? I've added indexes for both of the fields on which I do a SELECT DISTINCT. It seems to have helped a little, but the queries are still fairly slow.


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



Reply via email to