google app engine - Finding the largest value of an indexed property in AppEngine -


let's have several entities stored in appengine datastore have indexed numerical property , need find largest existing value.

i projection query sorted on property descending sort-order , limit of 1. returned result contain answer.

is best approach or there more efficient way value?

(consistency not of worry in case. if miss couple values being committed simultaneously, don't care much. so, no need transactions here.)

since gae datastore not have equivalent max on sql database, indeed best order column , retrieve first entry. example:

max_val = myentity.query().order(-myentity.my_numeric_field).get().my_numeric_field 

see this forum discussion.

your second option store maximum value in other entity , update (probably in transaction) whenever add 1 of first entities.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -