Hi everyone,
select sql_calc_found_rows DIST_NO from acquired WHERE FOLIO_NO='l01917' And STAT_FLAG <> 'Matched' union select DIST_NO from transfrd WHERE FOLIO_NO='l01917' And STAT_FLAG <> 'Matched' LIMIT 0, 5;
The above query takes more than 4.5secs
if i run the query without sql_calc_found_rows the execution time is 0.7 secs
select DIST_NO from acquired WHERE FOLIO_NO='l01917' And STAT_FLAG <> 'Matched' union select DIST_NO from transfrd WHERE FOLIO_NO='l01917' And STAT_FLAG <> 'Matched' LIMIT 0, 5;
the total records found in both acquired and transfrd table is more than 25 lakhs how to overcome this issue and one more thing is here i indexed both FOLIO_NO and STAT_FLAG in both the tables