I am using Linux_64 as the server. I need to do the statistics for the data over the specific time period.
Here is the problem I encountered: we have the existing tables with quite big number (531,576,443) of existing data. The following queries seem to take forever:
mysql> CREATE INDEX cal_name_index ON table1(cal_name);
mysql> select count(*) from table1 where table2_id in (select id from table2 where cal_name=desired_name and table3_id in (select id from table3 where date > '2010-11-27 00:00:00' and date < '2010-12-04 00:00:00'));
mysql> select * from table1 where table2_id in (select id from table2 where cal_name=desired_name and table3_id in (select id from table3 where date > '2010-11-27 00:00:00' and date < '2010-12-04 00:00:00')) limit 1;
It will be greatly appreciated if someone can give some suggestions for speeding up the fetching.
Here is the problem I encountered: we have the existing tables with quite big number (531,576,443) of existing data. The following queries seem to take forever:
mysql> CREATE INDEX cal_name_index ON table1(cal_name);
mysql> select count(*) from table1 where table2_id in (select id from table2 where cal_name=desired_name and table3_id in (select id from table3 where date > '2010-11-27 00:00:00' and date < '2010-12-04 00:00:00'));
mysql> select * from table1 where table2_id in (select id from table2 where cal_name=desired_name and table3_id in (select id from table3 where date > '2010-11-27 00:00:00' and date < '2010-12-04 00:00:00')) limit 1;
It will be greatly appreciated if someone can give some suggestions for speeding up the fetching.