java - Alternative strategy to query aggregation ("group by") in google app engine datastore -
app engine datastore cannot queried aggregate result.
example: have entity called "post" following fields:
key id, string nickname, string posttext, int score
i have many different nicknames , many posts each nickname in datastore.
if want leader board of top ten nicknames of total scores, typically have sql follows:
select nickname, sum(score) sumscore post group nickname order sumscore limit 10
this type of query not possible in google app engine datastore java api (jdo or jpa).
what alternative strategies use achieve similar result?
crudely , brutely, load every post entity , compute aggregation in application code. not efficient on large datasets.
what other strategies can employ?
create nickname
model, , each time add new post, retrieve corresponding nickname , increase stored score sum there. essentially, computation @ insert/update-time, not query-time.
Comments
Post a Comment