Cloud SQL for PostgreSQL FAQ


What is Google Cloud SQL?
Google Cloud SQL is an easy-to-use service that delivers fully managed SQL databases in the cloud. Google Cloud SQL provides either MySQL or PostgreSQL databases. Cloud SQL for PostgreSQL is currently in Beta release.
What are the benefits of using Google Cloud SQL?
Cloud SQL lets you hand off to Google the mundane, but necessary and often time consuming tasks — like applying patches and updates, managing backups and configuring replications — so you can put your focus on building great applications. And because we use standard wire protocols, it’s easy to connect from just about any application, anywhere.
Which database versions are available with Google Cloud SQL? How are updates managed?

Cloud SQL for PostgreSQL supports PostgreSQL 9.6. Minor version updates are deployed as they are released, with no further action required on your part. For more information about updates, see What kind of maintenance shutdowns should I expect with my instance?.

To see the current version of your instance, go to the Google Cloud Platform Console, click the instance name to open the Instance details page. Or, you can use the gcloud sql instances describe command.

Does Google Cloud SQL support all database features?
Google Cloud SQL supports most common features of PostgreSQL. For a list of all differences between standard PostgreSQL and the functionality Cloud SQL provides, see Differences between Google Cloud SQL and standard PostgreSQL functionality.
Are there any size or QPS limits?
There are no queries per second (QPS) limits for Google Cloud SQL instances. However, there are connection, size, and App Engine specific limits in place.

Cloud SQL for MySQL Second Generation connection limits

Machine type Maximum concurrent connections
db-f1-micro 250
db-g1-small 1,000
All other machine types 4,000

Cloud SQL for PostgreSQL connection limits

Memory size, in GiB Maximum concurrent connections*
0.6 (db-f1-micro) 25
1.7 (db-g1-small) 50
3.75 up to 6 100
6 up to 7.5 150
7.5 up to 15 200
15 up to 30 250
30 up to 60 300
60 up to 120 400
120 and above 500

*Cloud SQL for PostgreSQL reserves up to six of these connections for internal operations.

Cloud SQL for MySQL First Generation connection limits

Incoming connection requests are briefly queued before the connection is established. The queue can accept only 100 incoming connection requests.

Tier Maximum concurrent connections
D0 - D2 250
D4 500
D8 1,000
D16 2,000
D32 4,000

Cloud SQL storage limits

MySQL First Generation instances MySQL Second Generation instances PostgreSQL instances Notes
250 GB Up to 10,230 GB, depending on machine type Up to 10,230 GB, depending on whether the instance has dedicated or shared vCPUs. It is possible to increase individual First Generation instance limits up to 500 GB for customers with a Silver or higher Google Cloud support package.

App Engine Limits

Requests from App Engine applications to Cloud SQL are subject to the following time and connection limits:

  • For apps running in the Google App Engine standard environment, all database requests must finish within the HTTP request timer, around 60 seconds. For apps running in the flexible environment, all database requests must finish within 60 minutes.
  • Offline requests like cron tasks have a time limit of 10 minutes.
  • Requests to Cloud SQL have limitations based on the scaling type of the App Engine module and how long an instance can remain in memory (residence).
  • Each App Engine instance running in a standard environment cannot have more than 60 concurrent connections to a Cloud SQL instance.

App Engine applications are also subject to additional App Engine quotas and limits as discussed on the Quotas page.

How can I be notified when there are any changes to Google Cloud SQL?
You can sign up for the google-cloud-sql-announce forum where we post announcements and news about Google Cloud SQL.
How do I report a bug, request a feature, or ask a question?
You can report bugs and request a feature on our google-cloud-sql-discuss group. You can ask a question in Stack Overflow. For other support options, see the Google Cloud SQL Support page.

Back to top

Getting Started

Why does my new instance with no data show disk space used?
Cloud SQL and the database both use some space for system files and metadata when your instance is created.
Which activation policy should I use?
Generally, you should set your activation policy to ALWAYS. If you are not using your instance, you can set its activation policy to NEVER to avoid instance charges.

Back to top

Data Storage and Replication

Where is my data stored?

PostgreSQL instances: Instance data is stored in the region where the instance resides. Backup data is stored in two regions for redundancy. If there are two regions on a continent, the backup data remains on the same continent. Because there is only one region in Australia, backup data from the Sydney region is also stored in Asia.

What is a zone?

A zone is an independent entity in a specific geographical location where you can run your resources. For example, a zone named us-central1-a indicates a location in the central United States.

For more information about zones, see Zone Resources in the Google Compute Engine documentation.

What are the limits on storage?

PostgreSQL instances: You can configure the storage capacity of your instance from 10 GB to 10,240 GB (3062 GB for shared-core machine types). Instance capacity cannot be decreased, it can only be increased. You can also configure your instance to automatically increase its storage capacity when space is running low. Learn more.

How is my data replicated?

PostgreSQL instances provide a high availability configuration and read replicas.

How does Cloud SQL failover work?

For information about failover, see Overview of the High Availabilty Configuration.

Is my data encrypted?
Cloud SQL customer data is encrypted when stored in database tables, temporary files, and backups. External connections can be encrypted by using SSL, or by using the Cloud SQL Proxy.
How is encryption managed for data at rest?

Your data is encrypted using the 256-bit Advanced Encryption Standard (AES-256), or better, with symmetric keys: that is, the same key is used to encrypt the data when it is stored, and to decrypt it when it is used. These data keys are themselves encrypted using a master key stored in a secure keystore, and changed regularly.

For more details,see Encryption at Rest in Google Cloud.

How is encryption managed for data in transit?

Google encrypts and authenticates all data in transit at one or more network layers when data moves outside physical boundaries not controlled by Google or on behalf of Google. Data in transit inside a physical boundary controlled by or on behalf of Google is generally authenticated but might not be encrypted by default. You can choose which additional security measures to apply based on your threat model. For example, you can configure SSL for intra-zone connections to Cloud SQL.

For more details, see Encryption in Transit in Google Cloud.

What kind of read replicas can I create?

For more information about read replicas, including use cases for each type, see Replication Options.

Back to top

Backup and Recovery

How do I recover an instance?

To restore to a backup you can use the Google Cloud Platform Console or the Cloud SQL command-line tool. For more details, see Restoring an Instance.

How much do backups cost?

PostgreSQL instances: The most recent 7 automated backups, and all on-demand backups, are retained. They are charged at the backup storage rate.

For more information about instance storage pricing and instance rates, see Pricing.

Back to top

Managing Your Instances

Can I make my database larger or smaller?

You can increase the amount of storage available to your instance at any time without incurring downtime. You cannot decrease the size of the storage of your instance. You can also configure your instance to automatically increase its storage capacity when space is running low. Learn more.

Do I need to use the Google Cloud Platform Console to manage Google Cloud SQL?
No. All management tasks that can be done via the console can also be done programmatically via the Cloud SQL API, or scripted using the gcloud command-line tool.
How large a database can I use with Google Cloud SQL?

Your database instance can be up to 10,240 GB (3062 GB for shared-core machine types).

What kind of maintenance shutdowns should I expect with my instance?
You can select a maintenance window for your instance, so you can control when maintenance restarts occur. You can also specify whether an instance gets updates earlier or later than other instances in your project. Learn more.

We recommend that you design your applications to deal with situations when your instance is not accessible for short periods of time, such as in a maintenance shutdown. You can test the behavior of your application to a maintenance shutdown by restarting your instance, which has the same effect. In general, we recommend that you use only short-lived connections as well as use exponential back-off for retrying rejected connections. For more guidance see How should I manage connections?.

When a new version starts to be rolled out, a note is added to the Cloud SQL Release Notes. Note, however, that not all instances are upgraded to the new release at the same time.

Can I import or export a specific database?
Yes. You can only import or export a specific database; you cannot import or export more than one database at a time.
Can I import or export a CSV file?
PostgreSQL instances do not yet support CSV files for import or export.
Do I need a Cloud Storage account to import or export data to an instance?
Cloud SQL supports importing and exporting databases (compressed or uncompressed SQL dump files) using a Cloud Storage bucket. To import or export using a Cloud Storage bucket, you need to either sign up for a Cloud Platform account and create a bucket, or have access to a Cloud Storage bucket in another account. For more information, see Importing Data into Cloud SQL.
If I delete my instance, can I reuse the instance name?
Yes, but not right away. The instance name is unavailable for up to a week before it can be reused.
What is the cloudsqladmin database user?
Every Google Cloud SQL instance includes a database user called cloudsqladmin. You may notice this user if you do a SHOW GRANTS FOR cloudsqladmin@localhost. On some instances this will also show up in the system user table. This user account is used by automated processes that need to access the data in your instance (for example, backing up your instance or performing an import or export).

Back to top

Pricing and Billing

How can I try out Google Cloud SQL?
The smallest instance is the db-f1-micro. You can use it to try out the service. Note that shared core instances are not covered by the SLA.
How many instances can I create in a project?

A project can have up to 40 instances. Deleted instances do not count toward the instance limit. You can request that the instance limit be raised for a project by contacting the team.

A user can create up to 60 instances across all projects.

What size database instance do I need? How much RAM?
In general, you can increase the performance of your database by choosing a larger instance with more RAM and CPU. This increases the performance of many queries that involve large amounts of computation, such as those involving joins, ORDER BYs, or GROUPing, though the performance of updates affecting single rows will not be much affected. For more information about instance sizes and pricing, see the pricing page.
How is use of my instance calculated?

You are charged per minute for the time that your instance is on.

How is storage calculated?
Storage is calculated based on the amount of storage you have provisioned for your instance. Storage for backups is charged by how much space your backups are using. Storage is charged whether your instance is on or off.
How can I see how much I will be charged?
The Billing tab of the Google Cloud Platform Console shows you the charges your instances have incurred since the last bill was issued.
What happens when my instance reaches the allowed size?

If your instance reaches the provisioned storage size, and you do not have automatic storage increase enabled or it has reached its configured limit, future writes to the database are disallowed until you increase the storage size. Increasing the storage size does not require an instance restart or downtime.

Why is my instance suspended?
This is probably due to an issue with your Google Cloud Platform account. You can determine your billing status by filing a Billing Support Request. Note that suspended Second Generation instances are deleted after 90 days.
Why was my instance deleted?
Instances that are suspended for 90 days are deleted. This applies to instances with a state of SUSPENDED. Instances that are stopped, with a state of RUNNABLE, are not deleted.
How can I cancel my Google Cloud SQL account?
You can deactivate Google Cloud SQL for a project by visiting the Google Cloud Platform Console, selecting the project, selecting the API service to open the API Dashboard. Find the Google Cloud SQL API and click Disable for that API.
How do I disable billing?
You can disable billing by clicking Disable billing in the Google Cloud Platform Console Billing & settings pane for a project. If you disable billing, you also disable the Google Cloud SQL service. Make sure you really want to disable the Google Cloud SQL service before you disable billing.

After you disable billing, you will receive one last bill for charges that occurred between the beginning of the billing cycle and when you cancelled.

Back to top

Using Google Cloud SQL with App Engine

Can I connect from App Engine to a PostgreSQL instance?
Yes. You can connect from an App Engine application to a PostgreSQL instance, if the application is running in the flexible environment. For more information, see Connecting from Google App Engine.
Can my App Engine in the US access my Google Cloud SQL instance in the EU (and vice versa)?

If you are connecting to a PostgreSQL instance, your App Engine application does not need to be in the same region, and it must be running in the flexible environment. However, a larger distance between your Cloud SQL instance and your App Engine application causes greater latency for connections to the database.

Should I use Google Cloud SQL or Cloud Datastore?
This depends on the requirements of the application. Cloud Datastore provides NoSQL key-value storage that is highly scalable, but does not support the complex queries offered by a SQL database. Cloud SQL supports complex queries and ACID transactions, but this means that the database acts as a 'fixed pipe' and performance is less scalable. Many applications use both types of storage.
Do I need to install a local database server to use the App Engine Development Server?
No. You can configure App Engine to use either Cloud SQL or a locally installed database server when running on the development server.
What languages can I use to access my instance?
Google App Engine supports several languages that you can use to connect to your instances. For more information, see Connecting from Google App Engine.

If you are not using Google App Engine, you can use any language that has an associated connector or API.

Can I use Django with Google Cloud SQL?
Yes, Google Cloud SQL is compatible with Django. See Getting Started with Django.
Which placeholders can I use in my Python query string?
Python users can only use the %s format code in parameter substitution. Therefore, the following statement is invalid: cursor.execute('INSERT INTO entries (guestAge) VALUES (%d)', (age)).
How should I manage connections?

How to best manage your database connections depends on your use case but, in general, we recommend using connection pooling. Connection pooling will protect the database server from large numbers of new connections created too rapidly, which can impact performance.

In cloud-hosted environments, you should manage your database connections differently than managing them in a conventional, external server environment. We recommend that you design your applications to handle occasional connection failures by implementing an error handling strategy like exponential backoff. For an example, see Exponential backoff in the Google Cloud Storage documentation.

To learn more about instance connection limits, see the FAQ Are there any size or QPS limits?

What does a SQLException with message of "Invalid connection ID" mean?
It means that the connection is no longer open on the server and should be discarded by the client.  You do not need to call 'close' on these connections; they are already closed.
Can I access my Google Cloud SQL instance programmatically outside of App Engine?
Yes. You can access Google Cloud SQL instances programmatically from external applications using any supported language. You can also connect using JDBC, including writing Apps Script scripts to access your Google Cloud SQL databases. See Connecting from External Applications.

Back to top

Send feedback about...

Cloud SQL for PostgreSQL