Forum Moderators: open

Message Too Old, No Replies

Indexes

         

dougmcc1

2:41 pm on Sep 22, 2006 (gmt 0)

10+ Year Member



Given the following queries, what is the best index?

SELECT DISTINCTROW(field1) as field1 FROM google_data WHERE SUM(field2) = 0

SELECT SUM(field1) as sumField1,SUM(field2) as sumField2, SUM(field3) as sumField3, SUM(field4) as sumField4, SUM(field5) as sumField5, AVG(field6) as avgField6, AVG(field7) as avgField7, AVG(field8) as avgField8, AVG(field9) as avgField9,AVG(field10) as avgField10 FROM table_data WHERE field1='$value' AND (field11='$value2' OR field12='$value3')

Right now I have these indexes:

One for the first query which is an index on field2 with field1 added to it.

The other index is on field1 with all of the other fields from the second query added to it in the same order (field2 to field11).

I also have an individual index on fields 3-11.

Is there a better way to do it?