GAE Go 数据存储的大小

huangapple go评论72阅读模式
英文:

GAE Go size of datastore

问题

有没有一种函数可以调用来获取GAE Go Datastore中应用程序的条目数量,而不需要查询整个数据库并计算输出?

英文:

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?

答案1

得分: 3

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)

英文:
    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)

答案2

得分: 1

您可以在管理控制台的“数据”>“数据存储统计”下查看所有实体的大小。

这些统计数据可以通过PythonJava进行编程查询;我找不到Go的文档等效项。

英文:

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.

huangapple
  • 本文由 发表于 2011年12月7日 20:03:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/8415000.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定