A数据库获取(50把钥匙中的第()个似乎需要5-6秒。这正常吗?时间是什么函数?在
我还做了a.all(keys_only=True).filter('b=',b).fetch(1000),其中a.b是ReferenceProperty。我对数据存储进行了50次这样的往返,使用不同的b值,总时间只有3-4秒。在
这怎么可能?数据库获取()是并行执行的,只需访问一次数据存储,而且我认为按键查找实体比fetch更快。在
以下是我的A类的定义:
class App(db.Model):
name_atom = db.ReferenceProperty(AppName)
author = db.ReferenceProperty(Author)
short_desc = db.StringProperty()
description = db.TextProperty()
url = db.StringProperty()
rating_avg = properties.RangeProperty(0, 1000, default=0)
rating_count = properties.RangeProperty(min_value=0, default=0)
add_dt = db.DateTimeProperty(auto_now_add=True)
modify_dt = db.DateTimeProperty(auto_now=True)
更新
好吧,AppStats说:datastore_v3.Get real=2272ms api=416ms
我想发生的是我在做这个数据库获取([50个密钥])在同一个请求处理程序中进行大量其他低效数据存储调用之后,这只是速率限制。其他时候我也一样数据库获取()它在200毫秒内返回:)
不,要花几百毫秒。不过,你是怎么安排时间的?在
这也不无道理,往返50次。在
这是一个非常奇怪的结果,我认为可能有一些复杂的因素在起作用。正如David建议的那样,您应该使用AppStats来发现时间的去向。在
当按键获取实体时,查询时间主要取决于实体的大小。实体必须通过网络传输给你,然后解码。在
也许你的实体相当大?这也许可以解释为什么
keys_only
查询速度更快,尽管它包含了一个过滤器并获取了更多的结果。在您可以考虑使用AppStats,这样您就可以确切地知道为什么您的请求需要这么长时间。你甚至可以把它和你的问题放在一起。在
相关问题 更多 >
编程相关推荐