SELECT a, b,c, table1.a, e FROM table1, table2
WHERE (table1.a = table2.a and table2.id='111')
and TIME_TO_SEC(TIMEDIFF(NOW() , table2.time)) < 172800
我的查询属于这种类型,其中a和id是table1和table2中的索引。 这个查询需要很长时间才能执行。两个表都有数百万个数据。我该如何解决这个问题?如何控制两个表之间的mysql查询执行时间
数百万条记录需要什么?并告诉我们你到目前为止所尝试的。 – Max 2014-10-29 08:46:49
SELECT completedon,language,round_over.round_id,password FROM players_over,round_over WHERE(players_over.email ='1'and players_over.round_id = round_over.round_id)and TIME_TO_SEC(TIMEDIFF(NOW(),round_over.finishedon))<172800 – 2014-10-29 08:51:07
除了这段代码之外,你使用什么连接字符串?如果你使用'localhost',尝试使用'127.0.0.1',这会加快我的mysql查询。 – Azrael 2014-10-29 08:58:09