Reputation: 117
I am interested in knowing the best structure, for speed and cost efficiency, of Google App Engine Datastore entities.
As an example, an app about Clubs.
A single ndb.Model entity per club with: Name, ID, Address, Contacts, Tags, Reviews, Images etc
Multiple Entities per club with a KeyProperty referencing the club.
Considering that users might only want to look up addresses of Clubs close to their location, or perhaps only search for a contact number for one Club, or might scroll through pages of information about various Clubs; what is the better structure / best practice for speed and cost efficiency?
Thanks.
Upvotes: 0
Views: 170
Reputation: 629
Structure B, but all the extra models added as Structured Properties.
That will make the whole club a single entity
Upvotes: 1
Reputation: 41099
It all boils down to (a) reading pattern, and (b) writing pattern.
READ: If your most widely use-case is to show all the information about the club, keeping all information in a single entity will be a cheaper and a more efficient approach (one read instead of three).
WRITE: If your model includes many properties that are almost never changed and some properties that change very frequently, it's better to separate them into different entities, so that each update of a single entity does not trigger updates to all indexes.
It appears that in your example there are no reasons to split the entity into multiple models.
Upvotes: 1