谷歌应用程序引擎 GQL,如何以毫秒精度使用日期时间进行分页
您好,我在从 GQL 查询亚秒精度查询时遇到问题。想知道是否有人遇到类似的问题或解决方法。
问题的背景是我正在将许多对象一次性加载到谷歌数据存储中。因此,可以在一秒钟内添加数千个对象。
在检索时,当我想根据添加它们的日期时间进行分页时,我遇到了分页问题。 (最后添加的时间对于分页来说是理想的,因为它允许用户仅获取他们没有的数据。)
由于实体批次是在亚秒量程内添加的。如果我需要在同一秒内插入一批实体来开始分页,那么分页就会出现问题。
即使我尝试传入具有分数的日期时间对象,应用程序引擎一盒解决方案似乎也无法处理亚秒级查询。 即我有以下查询,其中传递了带有秒分数的日期时间对象。在本地,我正在运行 python 2.6。
test = GqlQuery("select * from table where lastupdated > :1",minimumTime)
如果minimumTime类似于10:00:00.0500,结果集仍可能包含lastUpdated在10:00:00.0100, 10:00的记录:00.0200 等..
我想解决方法可能是创建我自己的密钥格式,它需要自动增量。但只是想看看我是否缺少其他更简单的解决方案。
谢谢, 宁
Hi I have an issue on querying for subsecond accuracy queries from GQL.. Wondering if anyone had similar issues or workarounds.
The context to the problem is that I'm loading batches of many objects into the google data store at once. So thousands of objects could be added within a single second.
On retrieval, I run into the pagination issue when I'd like to page based on datetime of when they're added. (the last added time is ideal for paging as it allows users to get only the data that they don't have.)
Since the batches of entities are added in within a sub second quantum. The paging is problematic if I need to start paging with a batch of entities inserted in the same second.
seems app engine one box solution can't handle subsecond queries even if I try to pass in datetime objects that has fractions.
i.e. I have the following query where I pass in a datetime object with fractions of second. as locally i'm running python 2.6.
test = GqlQuery("select * from table where lastupdated > :1", minimumTime)
If the minimumTime is something like 10:00:00.0500, the result set could still contain records with lastUpdated at 10:00:00.0100, 10:00:00.0200 etc..
I'm thinking maybe the workaround is to create my own key format, which needs to be autoincrementing. But just wanted to see if there was any other simpler solutions i'm missing.
Thanks,
Ning
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要对 DateTime 进行分页;请改用光标。
Don't paginate on the DateTime; instead, use cursors.