Appengine NDB:放置880行,超过数据存储区写操作配额.为什么?

Irv*_*ing 2 google-app-engine python-2.7 app-engine-ndb google-cloud-datastore

我有一个应用程序,使用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()
Run Code Online (Sandbox Code Playgroud)

我已将索引修剪回一:

- kind: BeerMenu
  properties:
    - name: brewery
    - name: name
Run Code Online (Sandbox Code Playgroud)

根据SDK数据存储区查看器,每行是29个写操作,因此将生成25520个写入!我假设索引消耗了其余的写操作,但我不确切知道有多少,因为AppEngine只是说我超出了配额.

减少写操作次数的最佳策略是什么?

mji*_*son 8

默认情况下,除text和blob属性之外的所有属性都将编制索引.因此,如果对字符串属性进行deindex,则所有float属性,int属性和日期属性仍会被编入索引.您应该添加indexed=False到其他属性以减少写入.

index.yaml中列出的索引是属性索引的附加索引.index.yaml索引用于有序和关系查询之类的东西(即,带有date> date_property的查询将在index.yaml中生成一个条目).