I have a table with around 40 million rows, and I want to run something like this:
SELECT country, count(*) FROM `signups`
where `signed_up` > '2012-03-20 00:00:00'
group by country
Basically to get how many sign ups per country after certain dates (usually for the last week). There are around 400K sign-ups per day, and 40 million in total or so.
The query just doesn’t run for the last week, I get a ‘MySQL server has gone away’… Any ways of optimizing this?
Please use below query and add a index on signed_up column. You will surely get performance gain.
SELECT country, count(signup_id) FROM
signupswhere
signed_up> ‘2012-03-20 00:00:00’group by country
Regards,
Alok