j'ai beaucoup de requêtes qui sont écrites comme:Comment optimiser requête imbriquée
select thread_id as topic_id,title as topic
,
isnull((select count(*) from tblmessages b where thread_id=a.thread_id and is_approved='Y' and sort_level>1
group by b.thread_id
),0) as replies,
isnull((select count(*) from tblmessages b where thread_id=a.thread_id and isnull(new_post,'Y')='Y' and sort_level>1
group by b.thread_id
),0) as NewPost,
isnull((select count(*) from tblmessages b where thread_id=a.thread_id and isnull(is_approved,'N')='N' and sort_level>1
group by b.thread_id
),0) as NotClear,
sort_level,sort_index, from tblMessages a
where sort_level=1 and [email protected]
order by topic_id desc
S'il vous plaît me dire comment optimiser et de mieux pour écrire de telles requêtes. parce que j'ai des tables avec des records 5,00,000. Il faut donc beaucoup de temps et parfois des temps morts.
Merci
Est-ce cinq millions ou 50 millions d'enregistrements? –
@Marcele: son 5,00,000 –