How to find the value that has maximum duplicates in app engine datastore using Java? -


i have datastore stores cab booking details of customers. in admin console need display statistics admin, busiest location, peak hours, total bookings in particular location in particular day. busiest location need retrieve location number of cabs has been booked. should iterate through entire datastore , keep count or there method know location has maximum , minimum duplicates.

i using ajax call java servlet should return busiest location.

and need suggestion maintaining such stats page. should keep separate entity kind counters , stats , update everytime when customer books cab or logic correct iterating through entire datastore stats page. in advance.

there many unknowns data model , usage patterns offer specific solution, can offer few tips.

  1. updating counter every time create new record increase writing costs 2 write operations, may or may not significant.

  2. using keys-only queries cheap , fast. preferred method counting something, should try model data in such way keys-only query can give answer. example, if "trip" entity has property "id of starting point", , property indexed, can loop through locations using keys-only query count number of trips started each location.

assuming record lot of trips, , admin page visited/refreshed not frequently, keys-only queries approach way go. if admin page visited/refreshed many times per hour, may better off counters.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -