mysql一句sql查询速度越来越慢?
voice_file表有2000条数据,search_job_result表有250万条。
-
SQL code
sqlString = "select v.voice_file_id,time_to_sec(v.duration) as duration, " + "v.audio_channel,v.create_time, s.confidence_score,s.phrase_id, " + "time_to_sec(s.start_time) as start_time, time_to_sec(s.end_time) as end_time " + "from (select confidence_score, phrase_id, start_time, end_time, voice_file_id " + "from search_job_result limit "+(j * 100000)+",100000"+") s, voice_file v where s.voice_file_id = v.voice_file_id";
其中参数j是外层一个for循环的传入参数。即for(int j=0;j<25;j++).
现在的问题是当j为10以内时,查询速度很快,而j数值越大时,查询速度越来越慢。大家能帮我分析其中的原因吗?
是的啊
引用是否是因为limit a,b中的a需要大量时间去locate
简化sql
囧
关键问题不在于select里面的索引
而是在于where里面的索引
刚好你的voice_file_id在where里面
所以速度才超快
建立的复合索引在SQL语句 中使用到了