从网上找了些资料,考虑直接在SQL底层,直接只取当前页的数据,再绑定,这样效率应该会高些。
核心的SQL查询语句是这样的:
| 代码如下 | 复制代码 |
| select top @size * from (@sqlstring) a where @key < = (select min(@key) from (select top @star @key from (@sqlstring) a order by @key desc ) a) and @key >= (select min(@key) from (select top @end @key from (@sqlstring) a order by @key desc) a) order by @key desc |
|
其中:
@size:一页的数量;
@sqlstring:原始查询语句;
@key:关键字段/排序字段,它应是唯一字段;
@star:开始记录数索引,star = size*(p-1)+1;
@end:结束记录数索引,end = size*p+1;
若排序不同,则代码应做相应变化:
| 代码如下 | 复制代码 |
| select top @size * from (@sqlstring) a where @key > = (select max(@key) from (select top @star @key from (@sqlstring) a order by @key asc) a) and @key <= (select max(@key) from (select top @end @key from (@sqlstring) a order by @key asc) a) order by @key asc |
|
我就是这样构建取数据集的方法,然后把相关参数传进来,拼接查询,返回数据集绑定即可。
这个方案暂时未发现出错,效率也有所提升。
deepin20怎么新增字体? deepin20安装字体的教程
Linux如何给文件权限? linux给文件添加可执行权限的技巧
deepin20桌面图标样式怎么修改? deepin更换图标主题的技巧
virtualbox打不开虚拟机怎么办? linux无法访问virtualbox的解决办法
deepin怎么注销系统? deepin系统注销与切换用户的方法
Manjaro linux怎么调鼠标速度? Manjaro鼠标设置光标速度的技巧