Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

分页查询结果集有误 #8

Open
fengkuok opened this issue Oct 26, 2012 · 7 comments
Open

分页查询结果集有误 #8

fengkuok opened this issue Oct 26, 2012 · 7 comments
Assignees
Labels
Milestone

Comments

@fengkuok
Copy link
Member

分页查询时可能出现结果集重复或者有些数据干脆取不出来的问题。通常会在最后一页较为多见。暂时还没有想到应对策略。

@ghost ghost assigned fengkuok Oct 26, 2012
@zsword
Copy link
Member

zsword commented Oct 27, 2012

是不是根据页数计算数据开始序号那有问题?

@fengkuok
Copy link
Member Author

@zsword 错的一塌糊涂啊!
比如:
t_1表中数据id为1,3,5,7,9
t_2表中数据id为2,4,6,8,10

现在想每页显示两条数据,根据sql语句,我从t_1表中查询出数据为1,3。t_2表查询出数据2,4。
合并,排序后最终获得数据id为1,2。

翻第二也的时候。t_1查询出5,7。t_2查询出6,8。已经直接丢掉数据3和4了!

有没有什么好的算法?

@zsword
Copy link
Member

zsword commented Nov 1, 2012

直接建试图,或者全部合并,再分页查询吧。

@fengkuok
Copy link
Member Author

fengkuok commented Nov 1, 2012

@zsword
同库分表的话视图可以解决,但是没有并行查询,效率是问题。
不同库的话就麻烦了。hibernate shards里也有这个问题,竟然没有解决!

在 2012-11-1 上午9:52,"周士淳" notifications@github.com写道:

直接建试图,或者全部合并,再分页查询吧。


Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-9968573.

@songjiesdnu
Copy link

作者这个问题最终怎么解决的?

@bwzhang2011
Copy link

这个当前解决得怎么样了

@fengkuok
Copy link
Member Author

@songjiesdnu @bwzhang2011

这个问题在框架层面基本没有什么好的办法解决。有几种方案供大家参考:
1、假分页,根据结果重新计算。
2、将数据同步到NoSQL、Solr等进行跨分区查询。
3、从业务上避免类似操作。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants