Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

RE: Using index for group-by: Not working?

From: Andrew Armstrong <andrew(at)mammoth.com.au>
Date: Sat Jul 28 2007 - 23:31:53 EDT


It's just occurred to me that the IN clause is not a constant.

This probably throws out any chance of using an index for group by?

Cheers

-----Original Message-----
From: Andrew Armstrong [mailto:andrew@mammoth.com.au] Sent: Sunday, 29 July 2007 1:07 PM
To: mysql@lists.mysql.com
Subject: Using index for group-by: Not working?

Hi,  

I have the following query:  

SELECT c2, c3, c4, Count(DISTINCT c5)

FROM table1

Do you need help?X

WHERE c1 IN (1, 2, 3...)

GROUP BY c2, c3, c4

order by null  

Yet I can only get it at best to show (under extra): Using where, using filesort.  

I have read up on:

http://dev.mysql.com/doc/refman/5.0/en/loose-index-scan.html and
http://dev.mysql.com/doc/refman/5.0/en/distinct-optimization.html and
http://dev.mysql.com/doc/refman/5.0/en/explain.html yet cannot get this
index to be used.  

I am running MySQL '5.1.17-beta-community-nt-debug'  

There are over 600,000 rows in table1 for my testing.  

I have tried placing indexes on: idx(c2, c3, c4, c5) and idx(c1, c2, c3, c4, c5) and indx(c5, c1, c2, c3, c4) with no result.  

Do you need more help?X

Is there a reason I cannot get this query to use an index for grouping?  

Cheers,

Andrew

-- 
MySQL General Mailing List
For list archives: 
http://lists.mysql.com/mysql
To unsubscribe:    
http://lists.mysql.com/mysql?unsub=lists@pantek.com
Received on Sat Jul 28 23:32:50 2007

This archive was generated by hypermail 2.1.8 : Thu Aug 09 2007 - 19:29:33 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library