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

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

问题描述

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



我试图理解为什么这个操作如此昂贵以及如何保持配额不变。



  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,options = stringbool)
url = ndb.StringProperty()
bartender = ndb.StringProperty()
lineno = ndb.IntegerProperty()
purdate = ndb.DateProperty()
costper = ndb.FloatProperty()

我将索引修剪回一个:

   -  kind:BeerMenu 
属性:
- 名称:brewery
- name:name

Accordi在SDK数据存储区查看器中,每行都有29个写操作,因此会生成25520个写操作!我假设索引消耗了剩余的写操作,但我不知道究竟有多少,因为AppEngine只是说我超出了配额。



什么是减少写操作数量的最佳策略?解除方案

除文本和blob属性之外的所有属性都默认为索引。因此,如果您取消索引字符串属性,则所有的float,int和date属性仍会索引。您应该向其他属性添加 indexed = False 以减少写入操作。



index.yaml中列出的索引是额外的索引到属性索引。 index.yaml索引适用于有序查询和关系查询(即,具有date> date_property的查询将在index.yaml中生成一个条目)。


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.

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

I've trimmed the indexing back to one:

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

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?

解决方案

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.

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天全站免登陆