有多少数据存储读取消耗每个读取,计数和查询操作? [英] How many Datastore reads consume each Fetch, Count and Query operations?

查看:163
本文介绍了有多少数据存储读取消耗每个读取,计数和查询操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读Google App Engine中的许多用户群( Fig1 Fig2 图3 ),无法确定数据存储区中的大量数据存储区在其结算报告中的读数来自哪里。

您可能知道,数据存储读取数量限制为每天5万次操作,超出此预算,您必须付款。

I'm reading on Google App Engine groups many users (Fig1, Fig2, Fig3) that can't figure out where the high number of Datastore reads in their billing reports come from.
As you might know, Datastore reads are capped to 50K operations/day, above this budget you have to pay.

50K操作听起来像很多资源,但不幸的是,似乎每个操作(Query,Entity fetch,Count ..)隐藏了多个数据存储读取。

50K operations sounds like a lot of resources, but unluckily, it seems that each operation (Query, Entity fetch, Count..), hides several Datastore reads.

是否可以通过API或其他方法知道多少数据存储读取隐藏在公共 RPC.get RPC.runquery 调用?

Is it possible to know via API or some other approach, how many Datastore reads are hidden behind the common RPC.get , RPC.runquery calls?

Appstats 在这种情况下似乎没有用处,因为它只给出了RPC的详细信息,而不是隐藏的读取成本。

Appstats seems useless in this case because it gives just the RPC details and not the hidden reads cost.

拥有这样的简单模型:

class Example(db.Model):
    foo = db.StringProperty()    
    bars= db.ListProperty(str)

1000 实体,我对成本感兴趣

and 1000 entities in the datastore, I'm interested in the cost of these kind of operations:

items_count =  Example.all(keys_only = True).filter('bars=','spam').count()

items_count = Example.all().count(10000) 

items = Example.all().fetch(10000)

items = Example.all().filter('bars=','spam').filter('bars=','fu').fetch(10000)

items = Example.all().fetch(10000, offset=500)

items = Example.all().filter('foo>=', filtr).filter('foo<', filtr+ u'\ufffd')


推荐答案

请参阅 http://code.google.com/appengine/docs/billing.html #Billable_Resource_Unit_Cost
一个查询花费您1次读取,并为每个返回的实体读取1次读取。 返回包括被偏移量或计数跳过的实体。
因此,这1001读取每个这些:

See http://code.google.com/appengine/docs/billing.html#Billable_Resource_Unit_Cost . A query costs you 1 read plus 1 read for each entity returned. "Returned" includes entities skipped by offset or count. So that is 1001 reads for each of these:

Example.all(keys_only = True).filter('bars=','spam').count() 
Example.all().count(1000)
Example.all().fetch(1000)
Example.all().fetch(1000, offset=500)

对于这些,读取的数目是1加上数字与过滤器匹配的实体:

For these, the number of reads charged is 1 plus the number of entities that match the filters:

Example.all().filter('bars=','spam').filter('bars=','fu').fetch()
Example.all().filter('foo>=', filtr).filter('foo<', filtr+ u'\ufffd').fetch()

代替使用count,您应该考虑将计数存储在数据存储中,如果您需要每秒更新一次以上的次数。 http://code.google.com/appengine/articles/sharding_counters.html

Instead of using count you should consider storing the count in the datastore, sharded if you need to update the count more than once a second. http://code.google.com/appengine/articles/sharding_counters.html

只要有可能,您应该使用游标而不是偏移量。

Whenever possible you should use cursors instead of an offset.

这篇关于有多少数据存储读取消耗每个读取,计数和查询操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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