sql: sqlite: 服务器端分页
我有一个客户端与需要支持分页的服务器程序(使用sqlite3作为存储)进行通信。我正在考虑如何实施。一种方法:
1) user request page 1
a. execute query from sqlite3
b. return the first page range items to client
2) user request page N
a. execute query from sqlite3
b. return the N page range itmes to client
因此,在我的方法中,每次用户请求数据时,我都会重新发出查询并获取指定的元素,这似乎浪费时间......(与一次缓存所有项目并仅给出用户请求的部分相比,但是这种方法更复杂,因为我需要使缓存超时 - 用户正在使用浏览器我不知道用户何时注销并且缓存无用)
有更好的想法吗?
I have a client talking with server program(using sqlite3 as the storage) which needs to support paging. I am thinking about how to implement that. One approach:
1) user request page 1
a. execute query from sqlite3
b. return the first page range items to client
2) user request page N
a. execute query from sqlite3
b. return the N page range itmes to client
So in my approach every time user requests data I will re issue the query and get the specified elements, which seems waste of time...(comparing with caching all the items one time and just give the portion user asks, but this approach is more complex, as I need to timeout the cache - user is using browser I don't know when the user is loggout and the cache is useless)
Any better ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您可以使用
LIMIT…OFFET…
功能SQLite 的。摘自select 语法文档:
Maybe you could use the
LIMIT… OFFET…
capability of SQLite.Taken from the select syntax documentation: