Explanation of performance considerations of read/write on Google Datastore (GAE)? -


i'm having difficult time understanding mechanics of google app engine datastore.
want understand mechanics can build database in optimal way database.

given example below, can me in:

  1. structure database optimally
  2. understand performance of both read , write given structure

example:
let's have n baseball players , each has unique id.
i'd keep daily tally of homeruns hit each player (storing "total daily homeruns" property) , increment when homerun hit.
so, time increases, i'd show graph of homeruns each day each baseball player on x years.

player 1 1/21/2011 - 2 homeruns 1/22/2011 - 0 homeruns 1/23/2011 - 1 homeruns 

read requirement: read last 5 years of daily "homerun" data player?

write requirement: increment daily homerun count baseball player.

i love understand how structure data , mechanics of both read , write? simple storage task scale? all.

i model requirements one-to-many relationship this:

class player(db.model):   name = db.stringproperty()  class dailyhomeruns(db.model):   date = db.dateproperty()   counter = db.integerproperty()   player = db.referenceproperty(player) 

to retrieve dailyhomeruns of given player can in way:

daily_homeruns = dailyhomeruns.all().filter('player =', player)                                     .filter('date >', date_start)                                     .filter('date <=', date_end)                                     .order('date') 

read requirement:

google app engine performance queries scales size of result set , not size of data set.

this means if last 5 years homeruns query set contains in average 800 entities *, query performs same whether searches on thousand entities or million entities.

write requirement:
writes slow in google app engine scenario seems quite trivial , don't see possible contention/timeout problem; after need serially update dailyhomeruns incrementing counter small number of times per day.

other thoughts:
if need calculate stats, example total number of homeruns of given player ,don't think use gql purpose because not provide aggregate function à la sql.
instead, have design database upfront, defining model store total count of homeruns per player.
using transactions api, each time increment dailyhomeruns need increment totalhomeruns entity player.

* have estimated 3 matches per week 52 weeks multiplied per 5 years


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -