GAE Go数据存储区的大小

GAE Go数据存储区的大小

问题描述:

Is there some function one can call to get the amount of entries in the GAE Go Datastore of an app, without querying it for the whole database and counting the output?

是否可以调用某些函数来获取应用程序的GAE Go数据存储区中的条目数量,而无需查询 整个数据库并计算输出? p> div>

    c := appengine.NewContext(r)
    var result struct {
        Bytes int64 `datastore:"bytes"`
        Count int64 `datastore:"count"`
        Timestamp datastore.Time `datastore:"timestamp"`
    }
    datastore.NewQuery("__Stat_Total__").Run(c).Next(&result)
    c.Infof("count: %d", result.Count)

You can view the size of all entities in the admin console under Data > Datastore Statistics.

These stats can be queried programmatically from Python or Java; I couldn't find a documented equivalent for Go.