From: http://www.cnblogs.com/gzaaron/archive/2006/02/27/338908.html
After writing several pages, the speed is not high, and the bottleneck lies in SQL query. Too many tables and too many not in tables always filter a bit of data from large tables and data. I read a lot about SQL optimization. Article, Are strongly required not to use too many not in queries, it is best to replace it with table join. For example:
Select ID, name from table_a where id not in (select ID from table_ B)
This is the most classic not in query. Change to table joinCodeAs follows:
Select table_a.id, table_a.name from table_a left join table_ B on table_a.id = table_ B .id and table_ B .id is null
Or:
Select table_a.id, table_a.name from table_a left join table_ B on table_a.id = table_ B .id where table_ B .id is null
After trial, the effect was immediate, haha :)