The user with no hat
The user with no hat

Reputation: 10846

What eventual consistency means on GAE (HRD)?

From the GAE docs A query may include entities in the result set that should not have been included, or exclude entities that should have been included. Does this mean that a query such SELECT ORDERS FROM USERX can returns results from other users than USERX?

Upvotes: 1

Views: 80

Answers (2)

tx802
tx802

Reputation: 3564

Yes - you can think about the indexes lagging behind the entities to an extent. If you do a get-by-key, you will always get strong consistency – i.e., you will always get the 'correct' (latest) entity/ies.

Whenever you do a (non-ancestor) query, Datastore will scan one or more indexes. Those indexes may not (yet) reflect the latest values in the entity. "Eventually", they will be consistent, but there are no guarantees on when (the entity has to be replicated across different locations and the relevant indexes updated).

So, if you can (e.g., if you know what entity/ies you want to fetch), get-by-key is always good as you'll get strong consistency and avoid index scans.

If you need to do a query on some entities with strong consistency, you will need to give those entities a common ancestor, but be careful as it can often restrict you later (write rate in particular).

Upvotes: 2

Lipis
Lipis

Reputation: 21835

It means that you might get a result set that contains outdated entities, or entities that have been actually deleted, but not wrong entities in any way. In other words you might see cached results instead of the very fresh ones.

If that's an issue then you will have to use ancestors and limiting the results to a single entity group.

Upvotes: 1

Related Questions