Appengine NDB:放置 880 行,超出数据存储区写入操作配额.为什么? [英] Appengine NDB: Putting 880 rows, exceeding datastore write ops quota. Why?

查看:27
本文介绍了Appengine NDB:放置 880 行,超出数据存储区写入操作配额.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它使用 put_async() 将 880 行导入到 NDB 数据存储中.每当我运行此导入时,它都会超过对数据存储进行 50,000 次写入操作的每日配额.

I have an application which imports 880 rows into an NDB datastore, using put_async(). Whenever I run this import it exceeds the daily quota of 50,000 write ops to the datastore.

我试图了解为什么此操作如此昂贵,以及如何做才能保持在配额内.

I'm trying to understand why this operation is so expensive and what can be done to stay under quota.

有 13 列,如下所示:

There are 13 columns like so:

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()

我已将索引缩减为 1:

I've trimmed the indexing back to one:

- kind: BeerMenu
  properties:
    - name: brewery
    - name: name

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

According to the SDK datastore viewer, each row is 29 write ops, so that would generate 25520 writes! I'm assuming that the indexes consume the rest of the write ops, but I don't know exactly how many because AppEngine just says I've exceeded the quota.

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

What are the best strategies for reducing the number of write ops?

推荐答案

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

All properties except text and blob properties are indexed by default. So if you deindex the string properties, all the float, int, and date properties are still indexed. You should add indexed=False to the other properties to decrease writes.

index.yaml 中列出的索引是属性索引的附加索引.index.yaml 索引用于诸如有序查询和关系查询之类的内容(即,日期 > date_property 的查询将在 index.yaml 中生成一个条目).

Indexes listed in index.yaml are additional indexes to the property indexes. index.yaml indexes are for things like ordered and relational queries (i.e., a query with date > date_property will generate an entry in index.yaml).

这篇关于Appengine NDB:放置 880 行,超出数据存储区写入操作配额.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆