1 select id,start_member_id,start_date,modify_member_id,modify_date from formmain_0141 where id not in (select content_data_id from ctp_content_all where content_template_id='6890363387462501722' and content_data_id is not null ) limit 20000, 10000\G
Empty set (3 min 2.01 sec)
可見(jiàn),生產(chǎn)中,該語(yǔ)句運(yùn)行時(shí)間是3分2秒。
我們來(lái)看看其執(zhí)行計(jì)劃,為什么這么慢:
2、我改寫(xiě)后的索引,用的是 not exists ,內(nèi)外交互式子查詢(xún):
mysql> select id,start_member_id,start_date,modify_member_id,modify_date from formmain_0141 where not exists (select 1 from ctp_content_all where content_data_id= formmain_0141.id and content_data_id is not null and content_template_id='6890363387462501722') limit 20000, 10000 ;
Empty set (13.84 sec)