太多的写操作 [英] Too Many Write Ops
问题描述
我正在开发一个应用程序引擎(python)的目录应用程序,我遇到了太多的写操作问题。第一个问题是我有一个.NET脚本,它通过一个excel文件并将数据发布到我应用程序中的一个页面。当我运行它时,它已经获得了大约700条记录,并且我已经使用了我的写操作配额的75%。当我编写一个脚本来更新我的所有模型以为每个属性设置一个搜索字段时,就会发生同样的事情。我在大约20秒内从75%的配额上涨到96%,并且我在短时间内获得了太多写入的临时配额限制。我认为这个问题可能与索引有关,但当涉及到python和appengine时,我就是一个新手。以下是我的模型: 请参阅 http://code.google。 com / appengine / docs / python / datastore / propertyclass.html#属性 在您的情况下,如果 I'm developing a directory app on app-engine (python) and I've run into trouble with too many write ops. The first issue is that I have a .NET script that goes through an excel file and posts the data to a page in my app. When I ran it, it got through around 700 records and I had already used 75% of my write ops quota. The same thing happened when I wrote a script to update all of my models to have a search field for each property. I went from 75% of the quota filled to 96% in around 20 seconds and I got a temporary quota limit for too many writes in a short amount of time. I think the issue might be related to indexes but I'm sort of a newb when it comes to python and appengine. Here are my models :
Unless you target a property in a search (or use it for ordering), making them unindexed saves index writes. Each property is indexed twice (once ascending, once descending) unless either the property type is inherently unindexed, or you set See http://code.google.com/appengine/docs/python/datastore/propertyclass.html#Property In your case, if 这篇关于太多的写操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ p $ class AlumniEntry(db.Model):
为单个模型校友
author = db.UserProperty()
entered = db.DateTimeProperty(auto_now_add = True)
title = db.StringProperty()
first_name = db.StringProperty必需=真)
first_name_search = db.StringProperty()
maiden_name = db.StringProperty()
maiden_name_search = db.StringProperty()
spouse_name = db.StringProperty()
spouse_name_search = db.StringProperty()
grad_year = db.StringProperty(required = True)
elementary = db.StringProperty(choices =('yes','no','idk'),default ='idk')
class LastName(db.Model):
entry = db.ReferenceProperty(AlumniEntry,collection_name ='last_names')
last_name = db.StringProperty = True)
last_name_search = db.StringProperty()
PhoneNumber(db.Model):
entry = db.ReferencePro perty(AlumniEntry,collection_name ='phone_numbers')
number = db.PhoneNumberProperty(default = None)
class Email(db.Model):
entry = db.ReferenceProperty(
email = db.EmailProperty(default = None)
email_search = db.EmailProperty(default = None)
class Address(db.Model ):
entry = db.ReferenceProperty(AlumniEntry,collection_name ='addresses')
street = db.StringProperty()
street_search = db.StringProperty()
city = db。 StringProperty()
city_search = db.StringProperty()
state = db.StringProperty()
state_search = db.StringProperty()
zip_code = db.StringProperty()
class UserAuth(db.Model):
added_by = db.StringProperty(required = True)
user_id = db.StringProperty(required = True)
$ c $除非您在搜索中定位了一个属性(或者将其用于或者用于dering),使它们无索引保存索引写入。除非属性类型固有地未索引,或者您设置了 indexed = False
,否则每个属性都会索引两次(一次升序,一次降序)。
street_search
是用于搜索的标准化形式 street
,然后将 street
标记为索引= False
会节省2次写入。class AlumniEntry(db.Model):
"""Models an entry for a single alumni"""
author = db.UserProperty()
entered = db.DateTimeProperty(auto_now_add=True)
title = db.StringProperty()
first_name = db.StringProperty(required=True)
first_name_search = db.StringProperty()
maiden_name = db.StringProperty()
maiden_name_search = db.StringProperty()
spouse_name = db.StringProperty()
spouse_name_search = db.StringProperty()
grad_year = db.StringProperty(required=True)
elementary = db.StringProperty(choices=('yes', 'no', 'idk'), default='idk')
class LastName(db.Model):
entry = db.ReferenceProperty(AlumniEntry, collection_name='last_names')
last_name = db.StringProperty(required=True)
last_name_search = db.StringProperty()
class PhoneNumber(db.Model):
entry = db.ReferenceProperty(AlumniEntry, collection_name='phone_numbers')
number = db.PhoneNumberProperty(default=None)
class Email(db.Model):
entry = db.ReferenceProperty(AlumniEntry, collection_name='emails')
email = db.EmailProperty(default=None)
email_search = db.EmailProperty(default=None)
class Address(db.Model):
entry = db.ReferenceProperty(AlumniEntry, collection_name='addresses')
street = db.StringProperty()
street_search = db.StringProperty()
city = db.StringProperty()
city_search = db.StringProperty()
state = db.StringProperty()
state_search = db.StringProperty()
zip_code = db.StringProperty()
class UserAuth(db.Model):
added_by = db.StringProperty(required=True)
user_id = db.StringProperty(required=True)
indexed=False
.street_search
is a normalized form of street
used for searching, then marking street
as indexed=False
will save 2 writes.