//原先
select top 页大小 a.aid from 表1 a left join 表2 b on a.aid=b.aid where a.aid not in (select top 页索引*页大小 爱的 from
表1 a left join 表2 b on a.aid=b.aid where 条件) and 条件;
//优化后
with c as ( select rn=row_number() over(order by x.id),* from (select * from 表1 a left join 表2 b on a.aid=b.aid where 条件) x )
select * from c where rn between (页索引- 1) * 页大小 + 1 and 页索引*页大小
时间: 2024-10-09 21:01:17