Data consistency levels
Datastore queries can deliver their results at either of two consistency levels:
- Strongly consistent queries guarantee the freshest results, but may take longer to complete.
- Eventually consistent queries generally run faster, but may occasionally return stale results.
In an eventually consistent query, the indexes used to gather the results are also accessed with eventual consistency. Consequently, such queries may sometimes return entities that no longer match the original query criteria, while strongly consistent queries are always transactionally consistent.
Datastore query data consistency
Queries return their results with different levels of consistency guarantee, depending on the nature of the query:
- Ancestor queries (those within an entity group ) are strongly consistent by default, but can instead be made eventually consistent by setting the Datastore read policy (see below).
- Non-ancestor queries are always eventually consistent.
Fetching an entity by key, which is also called "lookup by key", is strongly consistent.
- Learn how to specify what a query returns and further control query results.
- Learn the common restrictions for queries on Datastore.
- Learn about query cursors, which allow an application to retrieve a query's results in convenient batches.
- Learn the basic syntax and structure of queries for Datastore.