简体   繁体   English

如何使用Google Cloud Datastore统计信息

[英]How to use Google Cloud Datastore Statistics

如何使用Google Cloud Datastore stats对象(在Python中)来获取数据库中满足给定约束(例如age> 20)的一种实体(即Person)的数量?

Query objects have a nice count method which you could use: 查询对象有一个不错的count方法,您可以使用:

qry = Person.query(Person.age > 20)
n_people_older_than_20 = qry.count()

Here I assume you're using the ndb queries (ie Person is an ndb.Model subclass). 在这里,我假设您正在使用ndb查询(即Personndb.Model子类)。 I'm sure that there's an equivalent for the older db interface as well ... 我敢肯定,还有一个等效的旧db接口...

You can't, that's not what it's for at all. 您不能,那根本不是全部。 It's only for very broad-grained statistics about the number of each types in the datastore. 仅用于关于数据存储中每种类型的数量的非常广泛的统计信息。 It'll give you a rough estimate of how many Person objects there are in total, that's all. 这将使您大致估计总共有多少个Person对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM