Datenkonsistenz in Datastore-Abfragen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Datenkonsistenzebenen
Die Ergebnisse von Datenspeicherabfragen können mit einer von zwei Konsistenzebenen bereitgestellt werden:
- Strikt konsistente Abfragen (Strong Consistency) garantieren die aktuellsten Ergebnisse, ihre Verarbeitung kann jedoch länger dauern.
- Abfragen mit Eventual Consistency werden im Allgemeinen schneller ausgeführt, können jedoch gelegentlich veraltete Ergebnisse zurückgeben.
Bei einer Abfrage mit Eventual Consistency wird auf die Indexe, von denen die Ergebnisse abgerufen werden, ebenfalls mit Eventual Consistency zugegriffen. Folglich geben solche Abfragen manchmal Entitäten zurück, die nicht mehr den ursprünglichen Abfragekriterien entsprechen, während Abfragen mit Strong Consistency immer konsistent sind.
Datenkonsistenz in Datastore-Abfragen
Die Ergebnisse von Abfragen werden je nach Art der Abfrage mit unterschiedlichen Konsistenzgarantieebenen zurückgegeben:
- Ancestor-Abfragen sind Abfragen innerhalb einer Entitätengruppe und standardmäßig strikt konsistent. Sie können jedoch durch Anpassung der Leserichtlinien für Cloud Datastore zu Eventual Consistency-Abfragen werden (siehe unten).
- Nicht-Ancestor-Abfragen sind immer Eventual-Consistency-Abfragen.
Der Abruf einer Entität nach Schlüssel, auch "Suche nach Schlüssel" genannt, ist stark konsistent.
Weitere Informationen
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-09-04 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eThis API supports first-generation runtimes and is relevant when upgrading to corresponding second-generation runtimes, with a migration guide available for those updating to App Engine Go 1.12+.\u003c/p\u003e\n"],["\u003cp\u003eDatastore queries have two consistency levels: strongly consistent queries, which provide the freshest results but may take longer, and eventually consistent queries, which are faster but may return stale results.\u003c/p\u003e\n"],["\u003cp\u003eAncestor queries are strongly consistent by default but can be made eventually consistent, whereas non-ancestor queries are always eventually consistent.\u003c/p\u003e\n"],["\u003cp\u003eFetching an entity by key is a strongly consistent operation.\u003c/p\u003e\n"],["\u003cp\u003eFurther learning resources are available on specifying query returns, restrictions, cursors, and the basic syntax of Datastore queries.\u003c/p\u003e\n"]]],[],null,["# Data Consistency in Datastore Queries\n\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| go\n| /services/access). If you are updating to the App Engine Go 1.12+ runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/go-differences) to learn about your migration options for legacy bundled services.\n\nData consistency levels\n-----------------------\n\nDatastore queries can deliver their results at either of two consistency\nlevels:\n\n- [*Strongly consistent*](https://en.wikipedia.org/wiki/Strong_consistency) queries guarantee the freshest results, but may take longer to complete.\n- [*Eventually consistent*](https://en.wikipedia.org/wiki/Eventual_consistency) queries generally run faster, but may occasionally return stale results.\n\nIn 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.\n\nDatastore query data consistency\n--------------------------------\n\nQueries return their results with different levels of consistency guarantee, depending on the nature of the query:\n\n- [Ancestor queries](/appengine/docs/legacy/standard/go111/datastore/queries#ancestor_queries) (those within an [entity group](./#Go_Ancestor_paths) ) are strongly consistent by default, but can instead be made eventually consistent by setting the Datastore read policy (see below).\n- Non-ancestor queries are always eventually consistent.\n\nFetching an entity by key, which is also called \"lookup by key\", is strongly\nconsistent.\n\nWhat's next?\n------------\n\n- [Learn how to specify what a query returns and further control query results](/appengine/docs/legacy/standard/go111/datastore/retrieving-query-results).\n- Learn the [common restrictions](/appengine/docs/legacy/standard/go111/datastore/query-restrictions) for queries on Datastore.\n- Learn about [query cursors](/appengine/docs/legacy/standard/go111/datastore/query-cursors), which allow an application to retrieve a query's results in convenient batches.\n- Learn the [basic syntax and structure of queries](/appengine/docs/legacy/standard/go111/datastore/queries) for Datastore."]]