Is there a way to do aggregate functions on Google App Engine?

二次信任 提交于 2019-11-28 00:53:44

Right: to use GAE storage properly, you need to selectively de-normalize some aspects of your model, keeping "redundant" data which, in a DB in normal form, you'd recompute on the fly, such as aggregates (overall and "grouped by" ones).

However, don't add such fields to the Person table in your case -- that makes little sense! Make another PersonAggregates table with columns such as City (null/missing for overall totals), Count, TotalAges (easier to maintain: compute the average at any time as total divided by count).

For frequently used aggregates the best is to update them on every update/insert/delete.

If you haven't designed such aggregates into your application from the start, you can run a script via Remote DataStore API or set up a server-side cron job that will process all entities and calculate the aggregates. It is fairly easy, just keep in mind per-request CPU quota.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!