网上看了很多关于exists和in的效率比较的文章,说exists比in高效,可是我试了一下,结果不是这样的。下面是我的sql语句,用了exists的很久都没出结果,cpu长时间处于100%的状态,烦请知道的指教一下,谢谢!
select * from doc_index t
where t.doc_id in (select doc_id from doc_cat_map where cat_id = 32 or cat_id = 13)select * from doc_index t 
where exists (select 'x' from doc_cat_map tt where t.doc_id = tt.doc_id and (tt.cat_id = 32 or tt.cat_id=13)) 表doc_index和doc_cat_map都有6万的数据;暂时不考虑索引的问题