[[["容易理解","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-08-17 (世界標準時間)。"],[],[],null,["# PGAdapter overview\n\nThis page provides an overview of PGAdapter. To learn how to start PGAdapter,\nsee [Starting PGAdapter](/spanner/docs/pgadapter-start).\n\nPGAdapter is a sidecar proxy which is a small application that runs\nalongside your main application to support communications between the [PostgreSQL interface for Spanner](/spanner/docs/postgresql-interface) and Spanner.\nFor Java applications you can even link PGAdapter to the application\ndirectly without having to run it in a separate process. PGAdapter is\ndesigned to run on the same machine as the application and exposes an\nendpoint on localhost that supports the PostgreSQL wire protocol. It\ntranslates the PostgreSQL wire protocol into the Spanner wire\nprotocol, gRPC. With this proxy running locally, a PostgreSQL client\nsuch as `psql` can connect to a PostgreSQL-dialect Spanner\ndatabase.\n\nPGAdapter adds, at most, 0.2 ms of latency overhead. The\nPostgreSQL interface has the same latency levels as\nGoogleSQL.\n| **Note:** [PostgreSQL drivers and ORMs](/spanner/docs/drivers-overview#postgresql_drivers_and_orms) lists all clients that PGAdapter supports.\n\nThe following diagram shows how `psql` connects to Spanner through\nPGAdapter.\n\nPGAdapter supports basic and extended query modes, and\nsupports any data type that the PostgreSQL interface for Spanner supports.\n\nPGAdapter execution environments\n--------------------------------\n\nYou can run PGAdapter by using one of the following methods:\n\n- **Standalone**: PGAdapter is supplied as a JAR file and runs standalone in the JVM.\n- **Docker**. PGAdapter is also packaged as a Docker image.\n- **Cloud Run**: PGAdapter can be deployed as a sidecar proxy on Cloud Run.\n- **Sidecar proxy**: a typical use as a sidecar proxy is in a Kubernetes cluster.\n- **In-process**: your Java application code can use the supplied JAR file to create and start a PGAdapter instance.\n\nFor details about these methods, see\n[Start PGAdapter](/spanner/docs/pgadapter-start).\n\nAuthorization with PGAdapter\n----------------------------\n\nPGAdapter determines the service account or other Identity and Access Management\n(IAM) principal to use for the connection by examining the\ncredentials that you specify when you start it. The IAM\npermissions granted to that principal determine the permissions that the\nconnecting application has on the database.\n\nWhen fine-grained access control is in use, you can optionally specify a\ndatabase role when you start PGAdapter. If you specify a database role,\nthen PGAdapter uses fine-grained access control when it sends requests for queries\nand DML statements. This requires the IAM permission\n`spanner.databases.useRoleBasedAccess` and, for database roles other than\n`public`, the `spanner.databaseRoles.use` permission. The privileges granted to\nthe database role determine the operations that the connecting application can\nperform. If you don't specify a database role, then the database-level\npermissions that are granted to the IAM\nprincipal are used. To perform DDL statements, the principal must have the\n`spanner.databases.updateDdl` permission.\n\nFor more information, see [About fine-grained access control](/spanner/docs/fgac-about) and\n[Access control with IAM](/spanner/docs/iam).\n\nWhat's next\n-----------\n\n- [Start PGAdapter](/spanner/docs/pgadapter-start)\n- Learn more about the [PGAdapter GitHub repository](https://github.com/GoogleCloudPlatform/pgadapter).\n- Learn more about [PostgreSQL drivers and ORMs](/spanner/docs/drivers-overview#postgresql_drivers_and_orms) for a table of PostgreSQL drivers and ORMs that PGAdapter supports."]]