Most efficient way to read many to many objects from GAE datastore

morpheus05

I've read some questions and articles about many to many relations in the google datastore but I'm still not sure which is the most efficient way in my case: I have a User which references N CollectionOfThings. A CollectionOfThings can reference M users. Both, M and N are very small. I except no more then 5. (Nature of my application). The user object is fetched almost in every request. The other object not. I need to query from an instance of CollectionOfThings all users and from a user all instances of her CollectionOfThing instances.

So I see to possible implementations:

  • CollectionOfThings has a List of Users. User has a collection of CollectionOfThings. Both ends of the relation are NOT annotated with @Load. If I need the objects of one the relatin parts I load them with ofy().load().keys();

  • I use a relation object which I can query ofy()....filter("user", ...) and vice versa.

Now the big question is: What is the most efficient way in perspective of data store read operations?

stickfigure

Start with the simplest/easiest approach, you can always migrate later. From what you describe, I would start with Set<Ref> fields pointing in both directions. You can use @Load groups so that the loads don't happen by default but you still have the facility available. Make sure to update both ends of the relationship in a transaction.

Another option, assuming the User<->CollectionOfThings relationship is symmetric bidirectional, is to only keep the Set of keys/refs on one side and @Index it. This has the advantage that you don't need a transaction to keep the bidir relationship in sync. It has the disadvantages that you use queries to follow the relationship in the inverse direction; those queries will be eventually consistent; it costs extra to maintain those indexes.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Most efficient way to have many inputs

From Dev

Most efficient way to use and communicate with many threads

From Dev

What's the most efficient way to resample from an array many times and take the mode of each sample?

From Dev

Efficient method to get all many to many objects from queryset

From Dev

Updating many(100k+) documents in the most efficient way MongoDB

From Dev

Most efficient way to find intersections between many sets of numbers

From Dev

More memory efficient way to define many objects of the same type

From Dev

Most efficient way to remove these objects

From Dev

Most efficient way to assign different things to objects made from the class?

From Dev

What is the most efficient way of accessing a property from an array of objects in PowerShell?

From Dev

Most efficient way to read two nodes from multiple XML files?

From

Most efficient way to read HTTP headers from a file?

From Dev

efficient way to select many records from oracle database(or in short time)

From Dev

Efficient way to extract coefficients from many linear regression lines

From Dev

GAE Cloud Datastore: Get most frequently read models

From Dev

How many requests can GAE Datastore handle simultaneously?

From Dev

What is the most efficient way to count how many rows in a dataframe were "active" for every minute of a day?

From Dev

What's the most resource efficient way to count how many files are in a directory?

From Dev

Database: most efficient way to organize tables with nested has-many relationship

From Dev

Efficient way to get most recent of many transaction nodes connected to a single account node by date

From Dev

How to create one to many relationships in neo4j graph in most efficient way?

From Dev

GAE Datastore read performance

From Dev

Initializing many objects in an elegant way

From Dev

What will be the most efficient way to filter the objects in django

From Dev

Restructuring JavaScript array of objects in the most efficient way

From Dev

Most efficient way to compare arrays of objects in typescript?

From Dev

Most efficient way of storing objects with corresponding indices

From Dev

Most efficient way of adding objects together

From Dev

What is the most efficient way to transform model of objects?

Related Related

  1. 1

    Most efficient way to have many inputs

  2. 2

    Most efficient way to use and communicate with many threads

  3. 3

    What's the most efficient way to resample from an array many times and take the mode of each sample?

  4. 4

    Efficient method to get all many to many objects from queryset

  5. 5

    Updating many(100k+) documents in the most efficient way MongoDB

  6. 6

    Most efficient way to find intersections between many sets of numbers

  7. 7

    More memory efficient way to define many objects of the same type

  8. 8

    Most efficient way to remove these objects

  9. 9

    Most efficient way to assign different things to objects made from the class?

  10. 10

    What is the most efficient way of accessing a property from an array of objects in PowerShell?

  11. 11

    Most efficient way to read two nodes from multiple XML files?

  12. 12

    Most efficient way to read HTTP headers from a file?

  13. 13

    efficient way to select many records from oracle database(or in short time)

  14. 14

    Efficient way to extract coefficients from many linear regression lines

  15. 15

    GAE Cloud Datastore: Get most frequently read models

  16. 16

    How many requests can GAE Datastore handle simultaneously?

  17. 17

    What is the most efficient way to count how many rows in a dataframe were "active" for every minute of a day?

  18. 18

    What's the most resource efficient way to count how many files are in a directory?

  19. 19

    Database: most efficient way to organize tables with nested has-many relationship

  20. 20

    Efficient way to get most recent of many transaction nodes connected to a single account node by date

  21. 21

    How to create one to many relationships in neo4j graph in most efficient way?

  22. 22

    GAE Datastore read performance

  23. 23

    Initializing many objects in an elegant way

  24. 24

    What will be the most efficient way to filter the objects in django

  25. 25

    Restructuring JavaScript array of objects in the most efficient way

  26. 26

    Most efficient way to compare arrays of objects in typescript?

  27. 27

    Most efficient way of storing objects with corresponding indices

  28. 28

    Most efficient way of adding objects together

  29. 29

    What is the most efficient way to transform model of objects?

HotTag

Archive