Given below entity
in google app engine datastore, is it better to define index on reportingIds
or define a separate entity which has only personId
and reportingIds
fields?
Based on the documentation I understood, defining index results in increase of count of operations against datastore quota.
Below are entities in GAE Go. My code needs to scan through Person entities frequently. It needs to limit its scan to Person entity that has at least 1 reporting person. 2 approaches I see.
- Define index on reportingIds and
Query
by specifying filters. - Create/Update PersonWithReporters entity when ever a Person gets a new reporting person.
PersonWithReporters
and need not construct any index/query. I can iterate using Key which is always guaranteed to have the latest data. Not sure which approach is beneficial considering datastore operation counts against quota limit.
type Person struct {
Id string //unique person id
//many other personal details, his personal settings etc
reportingIds []string //ids of the Person this guy manages
}
type PersonWithReporters struct {
Id string //Person managing reportees
reportingIds []string //ids of the Person this guy manages
}