I am using an InnoDB table that currently has 16m of records. When I run the following query by using MySQL Workbench, it returns in about 14 seconds:
SELECT countryCode AS label, SUM(count) AS value
FROM AnalyticsPieCharts
GROUP BY label
ORDER BY value DESC;
When I run the same query from a different computer, while the first one is running, both return in about 23-24 seconds.
I haven't created any indexes (except of the primary key) or put transaction rules. I am using Amazon RDS.
Do you have any clue on what could be the problem?
I managed to solve it by myself. I found a pattern in the data, that allowed me to split the data into unique chunks and count the chunks later, when needed. This way I reduced the size of the database by 300 times. Now the queries return in 1 second and the total amount of the non-chunked table (the big table) is now 120mln records.