【发布时间】:2013-06-09 08:16:28
【问题描述】:
我有一个使用 put_async() 将 880 行导入 NDB 数据存储的应用程序。每当我运行此导入时,它都会超过 50,000 次数据存储的每日写入操作配额。
我试图了解为什么这项操作如此昂贵,以及如何才能保持在配额之下。
有 13 列,如下所示:
stringbool = ['true', 'false']
class BeerMenu(ndb.Model):
name = ndb.StringProperty()
brewery = ndb.StringProperty()
origin = ndb.StringProperty()
abv = ndb.FloatProperty()
size = ndb.FloatProperty()
meas = ndb.StringProperty()
price = ndb.FloatProperty()
active = ndb.StringProperty(default="false", choices=stringbool)
url = ndb.StringProperty()
bartender = ndb.StringProperty()
lineno = ndb.IntegerProperty()
purdate = ndb.DateProperty()
costper = ndb.FloatProperty()
我已将索引缩减为一个:
- kind: BeerMenu
properties:
- name: brewery
- name: name
根据 SDK 数据存储查看器,每行是 29 次写入操作,因此将生成 25520 次写入!我假设索引消耗了其余的写入操作,但我不知道具体有多少,因为 AppEngine 只是说我已经超出了配额。
减少写入操作次数的最佳策略是什么?
【问题讨论】:
-
更新:我意识到 ndb.StringProperty() 默认是索引的。通过在其中许多项目上设置 indexed=False,我可以将写入操作减少到 18。我仍然不了解与 index.yaml 的关系。
标签: google-app-engine python-2.7 google-cloud-datastore app-engine-ndb