select * from (
select t_tmp_a.*, rownum t_tmp_id from (
select t.*, i.counts
from table1 t, (select id, count(id) counts from table2 group by id) i
where t.id=i.id and t.kindid in (0,1,3) order by t.id desc
) t_tmp_a where rownum <= 20) t_tmp_b where t_tmp_id >= 11;
table1 和 table2 每张表有超过 200 万条数据,执行这个查询需要 18 秒,在这个查询执行之前我们应该计算总计数大约需要 7 秒,所以它花费了 25 秒以上,有什么优化的想法吗?