Hi, is the following behaviour intended? Are my queries wrong? The output shows only the "Extra" field as the other fields are identical in all cases.
EXPLAIN SELECT t_refdb.refdb_id FROM t_refdb WHERE t_refdb.refdb_id>0 ORDER BY t_refdb.refdb_id; => Using where; Using index (results are sorted) EXPLAIN SELECT DISTINCT t_refdb.refdb_id FROM t_refdb WHERE t_refdb.refdb_id>0 ORDER BY t_refdb.refdb_id; => Using where; Using index (results are sorted) EXPLAIN SELECT t_refdb.refdb_id FROM t_refdb WHERE refdb_type!='DUMMY' AND t_refdb.refdb_id>0 ORDER BY t_refdb.refdb_id; => Using where; Using filesort (results are sorted) EXPLAIN SELECT DISTINCT t_refdb.refdb_id FROM t_refdb WHERE refdb_type!='DUMMY' AND t_refdb.refdb_id>0 ORDER BY t_refdb.refdb_id; => Using where (results are not sorted) That is, if MySQL can't use an index to sort the result, DISTINCT queries won't be sorted at all. These results were obtained with: mysql Ver 14.7 Distrib 4.1.21, for portbld-freebsd6.1 (i386) using 5.0 FreeBSD yeti.mininet 6.1-RELEASE FreeBSD 6.1-RELEASE #1: Mon Aug 28 22:24:48 CEST 2006 [EMAIL PROTECTED]:/usr/src/sys/i386/compile/YETI i386 regards, Markus -- Markus Hoenicka [EMAIL PROTECTED] (Spam-protected email: replace the quadrupeds with "mhoenicka") http://www.mhoenicka.de -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]