I have what I believe is a very basic query but it is taking a very long time to run.

Specifics of my MySQL Server:

* Ubuntu Server 14.04, 64-bit running as a VMWare Workstation virtual machine
* 2GB of RAM dedicated to the VM

The table I'm running the query on has 33 columns: a timestamp, and 32 columns with well names (e.g. LEW91\_4). There are about 2.5 million records in the table currently. The well columns are of datatype float. Indexes are:

* Column: ndx, Index: PRIMARY
* Column: t\_stamp, Index: C1\_Flowst\_stampndx

The Query:

```
    SELECT 
     DATE_FORMAT(t_stamp, '%m/%d/%Y %h:00 %p') as 'Date',
     AVG(LEW91_1R97) as 'LEW91_1R97',
     AVG(LEW91_2R97) as 'LEW91_2R97',
     AVG(LEW91_3R97) as 'LEW91_3R97',
     AVG(LEW91_4) as 'LEW91_4',
     AVG(LEW97_1) as 'LEW97_1',
     AVG(LEW97_3) as 'LEW97_3',
     AVG(LEW97_4) as 'LEW97_4',
     AVG(LEW97_6) as 'LEW97_6',
     AVG(LEW97_7) as 'LEW97_7',
     AVG(LEW97_8) as 'LEW97_8',
     AVG(LEW97_12) as 'LEW97_12'

    FROM C1_Flows
    WHERE DAY(t_stamp) = 28
    AND MONTH(t_stamp) = 09
    AND YEAR(t_stamp) = 2015
    GROUP BY DAY(t_stamp), HOUR(t_stamp)

```

The query is currently taking roughly 11 seconds to run when I run it from MySQL Workbench. When it runs from within the Java-based interface I'm using to develop an HMI, it times out with the specific error "Read timed out."

I've run much more complex queries on similar servers (i.e. joins, unions, if statements, etc.) and they run faster than this one. Is there a way I can speed this up or am I missing something obvious?