Go 1.11 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、Go 1.11 アプリケーションをデプロイできなくなります。既存の Go 1.11 アプリケーションは、
非推奨日以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの Go に移行することをおすすめします。
Datastore の概要
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Datastore モードの Firestore(Datastore)は、自動スケーリングと高パフォーマンスを実現し、アプリケーション開発を簡素化するように構築された NoSQL ドキュメント データベースです。Datastore の特長は次のとおりです。
- アトミック トランザクション: Datastore は、結果が「すべて成功」と「何も起こらない」のどちらかになる一連のオペレーションを実行できます。
- 可用性の高い読み取り / 書き込み処理: Datastore は、障害発生点からの影響を最小限に抑える冗長性を備えた Google データセンターで実行されています。
- 優れたスケーラビリティと高いパフォーマンス: Datastore は分散アーキテクチャを使用して自動的にスケーリングを管理します。インデックスとクエリの制約を組み合わせることで、データセットのサイズではなく結果セットのサイズに応じてクエリをスケールします。
- 柔軟なストレージとデータのクエリ: Datastore はオブジェクト指向の言語やスクリプト言語に自然に対応させることが可能で、複数のクライアントを通じてアプリケーションに公開されています。また SQL ライクなクエリ言語も提供しています。
- 強整合性: Datastore では、すべてのクエリが強整合性になります。
- 保存時の暗号化: Datastore はディスクに書き込む前に自動的にすべてのデータを暗号化し、承認されたユーザーがデータを読み取るときに自動的に復号します。詳細については、サーバー側の暗号化をご覧ください。
- 計画的なダウンタイムのないフルマネージド サービス: サービスの管理は Google が行うため、デベロッパーはアプリケーションに集中できます。サービスが予定されたアップグレードを受けるときにも、アプリケーションは引き続き Datastore を使用できます。
リレーショナル データベースとの比較
Datastore のインターフェースは、リレーショナル データベースと同様の機能を多数備えていますが、これは NoSQL データベースのため、データ オブジェクト間の関係を表現する方法は異なります。ここでは Datastore とリレーショナル データベースのコンセプトをおおまかに比較します。
コンセプト |
Datastore |
Firestore |
リレーショナル データベース |
オブジェクトのカテゴリ |
種類 |
コレクション グループ |
テーブル |
オブジェクト単体 |
エンティティ |
ドキュメント |
行 |
オブジェクトの個々のデータ |
プロパティ |
フィールド |
列 |
オブジェクトの一意の ID |
キー |
ドキュメント ID |
主キー |
リレーショナル データベースのテーブルの行とは異なり、Datastore では同じ種類のエンティティが異なるプロパティを持つ場合があります。また別々のエンティティが同じ名前のプロパティを持ちながら、値の型が異なる場合もあります。このような独自の特徴から、自動的にスケールする能力を活用するためにデータを設計、管理する方法が異なります。特に、Datastore は次の重要な動作方法が従来のリレーショナル データベースとは異なります。
- Datastore は非常に大規模なデータセットに対して自動的にスケールできるように設計されているため、アプリケーションが大量のトラフィックを受信しても高いパフォーマンスを維持できます。
- Datastore の書き込み処理は、必要に応じて自動的にデータを分散することでスケールされます。
- Datastore では、データセットのサイズではなく結果セットのサイズに応じてパフォーマンスがスケールするクエリだけがサポートされているため、読み取り処理がスケールされます。つまり、結果セットに 100 件のエンティティが含まれるクエリは、100 件を超えるエンティティを検索した場合でも同じパフォーマンスを発揮します。これは 100 万件になっても同じです。この特徴が、一部のタイプのクエリがサポートされていない主な理由となっています。
- すべてのクエリは構築済みのインデックスによって提供されるため、実行できるクエリのタイプは、SQL を使用するリレーショナル データベースで許可されているものよりも制限が厳しくなります。特に Datastore では、結合オペレーションや複数のプロパティに対する不等式フィルタリング、サブクエリの結果に基づいたデータに対するフィルタリングがサポートされていません。
- リレーショナル データベースではスキーマが強制されますが、Datastore はスキーマレスです。同じ種類のエンティティであってもプロパティ セットの一貫性は求められません(ただし、独自のアプリケーション コードでこのような要件を強制することもできます)。
最適な用途
Datastore は、大規模な構造化データに対して可用性の高いアクセスを必要とするアプリケーションに最適です。Datastore は、次のようなタイプのすべてのデータを保存、クエリする目的で使用できます。
- 小売店向けにリアルタイムな在庫と商品の詳細を提供する商品カタログ
- ユーザーの過去の行動と好みに応じてカスタマイズされたエクスペリエンスを提供するユーザー プロフィール
- ある銀行口座から別の口座への送金など、ACID プロパティに基づくトランザクション
ストレージとデータベースに関するその他のオプション
Datastore はすべてのユースケースに適しているわけではありません。たとえば、Datastore はリレーショナル データベースではないため、分析データに対する効果的なソリューションとはいえません。
ここでは Datastore 以外のソリューションを検討すべき一般的なシナリオを示します。
- SQL を完全にサポートするオンライン トランザクション処理(OLTP)システム向けのリレーショナル データベースが必要な場合は、Cloud SQL を検討してください。
- ACID トランザクションのサポートが不要な場合、またはデータが高度に構造化されていない場合は、Bigtable を検討してください。
- オンライン分析処理(OLAP)システムでのインタラクティブなクエリが必要な場合は、BigQuery を検討してください。
- 大容量の画像やムービーなど、大規模な不変 blob を格納する必要がある場合は、Cloud Storage を検討してください。
他のデータベース オプションについて詳しくは、データベース サービスの概要をご覧ください。
次のステップ
App Engine と Datastore の接続
App Engine の Go スタンダード ランタイムは、Go Datastore API を使用して Datastore に接続します。datastore
パッケージの内容の詳細については、datastore
パッケージ リファレンスをご覧ください。
App Engine スタンダード環境では、Go アプリケーションで Cloud Datastore クライアント ライブラリを使用できません。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-03 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-03 UTC。"],[[["\u003cp\u003eFirestore in Datastore mode (Datastore) is a NoSQL document database designed for automatic scaling, high performance, and easy application development.\u003c/p\u003e\n"],["\u003cp\u003eDatastore offers features like atomic transactions, high availability, massive scalability, flexible data storage and querying, strong consistency, encryption at rest, and is fully managed with no planned downtime.\u003c/p\u003e\n"],["\u003cp\u003eUnlike relational databases, Datastore is schemaless and designed to automatically scale to very large datasets, supporting only queries that scale with the result set size.\u003c/p\u003e\n"],["\u003cp\u003eDatastore is ideal for applications requiring highly available structured data at scale, such as product catalogs, user profiles, and ACID transactions.\u003c/p\u003e\n"],["\u003cp\u003eAlternative database options to Datastore are recommended for relational databases with full SQL support, non-structured data, interactive querying, or large immutable blobs such as images or movies.\u003c/p\u003e\n"]]],[],null,["# Datastore Overview\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\n\u003cbr /\u003e\n\nFirestore in Datastore mode (Datastore) is a NoSQL document database built for automatic scaling, high performance,\nand ease of application development. Datastore features include:\n\n- **Atomic transactions**. Datastore can execute a set of operations where either all succeed, or none occur.\n- **High availability of reads and writes**. Datastore runs in Google data centers, which use redundancy to minimize impact from points of failure.\n- **Massive scalability with high performance**. Datastore uses a distributed architecture to automatically manage scaling. Datastore uses a mix of indexes and query constraints so your queries scale with the size of your result set, not the size of your dataset.\n- **Flexible storage and querying of data** . Datastore maps naturally to object-oriented and scripting languages, and is exposed to applications through multiple clients. It also provides a SQL-like [query language](/datastore/docs/apis/gql/gql_reference).\n- **Strong consistency**. Datastore ensures that all queries are strongly consistent.\n- **Encryption at rest** . Datastore automatically encrypts all data before it is written to disk and automatically decrypts the data when read by an authorized user. For more information, see [Server-Side Encryption](/datastore/docs/concepts/encryption-at-rest).\n- **Fully managed with no planned downtime**. Google handles the administration of the service so you can focus on your application. Your application can still use Datastore when the service receives a planned upgrade.\n\nComparison with relational databases\n------------------------------------\n\nWhile the Datastore interface has many of the same features\nsimilar to relational databases, as a NoSQL database, it varies in how it\ndescribes the relationships between data objects. Here's a high-level comparison\nof Datastore and relational database concepts:\n\nUnlike rows in a relational database table, Datastore entities of\nthe same kind can have different properties, and different entities can have\nproperties with the same name but different value types. These unique\ncharacteristics imply a different way of designing and managing data to take\nadvantage of the ability to scale automatically. In particular,\nDatastore differs from a traditional relational database in the\nfollowing important ways:\n\n- Datastore is designed to automatically scale to very large data sets, allowing applications to maintain high performance as they receive more traffic:\n - Datastore writes scale by automatically distributing data as necessary.\n - Datastore reads scale because the only queries supported are those whose performance scales with the size of the result set (as opposed to the data set). This means that a query whose result set contains 100 entities performs the same whether it searches over a hundred entities or a million. This property is the key reason some types of queries are not supported.\n- Because all queries are served by previously built indexes, the types of queries that can be executed are more restrictive than those allowed on a relational database with SQL. In particular, Datastore does not include support for join operations, inequality filtering on multiple properties, or filtering on data based on results of a subquery.\n- Unlike relational databases which enforce a schema, Datastore is schemaless. It doesn't require entities of the same kind to have a consistent set of properties (although you can choose to enforce such a requirement in your own application code).\n\nWhat it's good for\n------------------\n\nDatastore is ideal for applications that rely on highly available structured data at scale. You can use Datastore to store and query all of the following types of data:\n\n- Product catalogs that provide real-time inventory and product details for a retailer.\n- User profiles that deliver a customized experience based on the user's past activities and preferences.\n- Transactions based on [ACID](https://en.wikipedia.org/wiki/ACID) properties. For example, transferring funds from one bank account to another.\n\nOther storage and database options\n----------------------------------\n\nDatastore is not ideal for every use case. For example, Datastore is not a relational database, and it is not an effective solution for analytic data.\n\nHere are some common scenarios where you should probably consider an alternative to Datastore:\n\n- If you need a relational database with full SQL support for an online transaction processing (OLTP) system, consider [Cloud SQL](/sql).\n- If you don't require support for ACID transactions or if your data is not highly structured, consider [Bigtable](/bigtable).\n- If you need interactive querying in an online analytical processing (OLAP) system, consider [BigQuery](/bigquery).\n- If you need to store large immutable blobs, such as large images or movies, consider [Cloud Storage](/storage).\n\n\nFor more information about other database options, see the [overview\nof database services](/products/databases).\n\nWhat's next\n-----------\n\n- [Learn how to store and query data using the Google Cloud console](/datastore/docs/store-query-data)\n- [Learn about the Datastore data model](/datastore/docs/concepts/entities)\n- [View best practices for Datastore](/datastore/docs/best-practices)\n\nConnecting to Datastore with App Engine\n---------------------------------------\n\nApp Engine's Go standard runtime connects to Datastore using the [Go\nDatastore API](/appengine/docs/legacy/standard/go111/datastore/api-overview). For a complete list of the contents of the\n`datastore` package, see the [`datastore` package reference](/appengine/docs/legacy/standard/go111/reference/latest/datastore).\n\nYou cannot use the [Cloud\nDatastore client library](/datastore/docs/reference/libraries#client-libraries-install-go) with Go applications in the App Engine standard\nenvironment."]]