Configure an instance's database flags

This page describes how to add database flags for an instance, modify database flags, and delete database flags from an instance in an AlloyDB for PostgreSQL cluster.

You use database flags for many operations, including adjusting PostgreSQL parameters, adjusting options, and configuring and tuning an instance. Modifications to a database flag's value persist for its instance until you remove the flag or you modify its value again.

In some cases, setting one flag may require that you set another flag to fully enable the desired functionality.

After you set, remove, or modify a flag for a database instance, AlloyDB might restart the instance. This depends upon the flag, as listed in Supported database flags.

When you modify a database flag in the primary or a read pool instance that needs a restart, you can choose one of the following maintenance policies:

  • Low downtime. This policy is enabled by default. We recommend using this policy for all your production AlloyDB clusters because it minimizes application downtime.

    With the low downtime policy enabled, updating a flag that requires a restart on your cluster's primary instance has these effects:

    • The primary instance experiences less than one second of downtime for most workloads.

    • The flag on the primary instance finishes updating to its new value after about 15 minutes.

    Updating a flag that requires a restart on a read pool instance has these effects:

    • The read pool instance does not require any downtime.

    • The flag on the read pool instance finishes updating to its new value after about 10 minutes.

  • Force apply. To apply flag updates faster, use the FORCE_APPLY option with the gcloud beta alloydb instances update command.

    This policy is more appropriate for development environments, letting you quickly add or modify flags in exchange for longer instance downtime and a temporary decrease in database performance or throughput. Your cluster returns to peak performance several minutes after force applying a flag update.

    With the force apply policy enabled, updating a flag that requires a restart on your cluster's primary instance has these effects:

    • The primary instance experiences about one minute of downtime.

    • The flag on the primary instance finishes updating to its new value after one or two minutes.

    Updating a flag that requires a restart on a read pool instance has these effects:

    • The read pool instance experiences about one minute of downtime.

    • The flag on the read pool instance finishes updating to its new value after one or two minutes.

Before you begin

  • The Google Cloud project you are using must have been enabled to access AlloyDB.
  • You must have one of these IAM roles in the Google Cloud project you are using:
    • roles/alloydb.admin (the AlloyDB Admin predefined IAM role)
    • roles/owner (the Owner basic IAM role)
    • roles/editor (the Editor basic IAM role)

    If you don't have any of these roles, contact your Organization Administrator to request access.

Console

  1. In the Google Cloud console, go to the Clusters page.

    Go to Clusters

  2. Click a cluster in the Resource Name column.

  3. In the Overview page, go to Instances in your cluster, select an instance, and then click Edit.

  4. Add, modify, or delete a database flag from your instance:

    Add a flag

    1. To add a database flag to your instance, click Add flag.
    2. Select a flag from the New database flag list.
    3. Provide a value for the flag.
    4. Click Done.

    Modify a flag

    1. To modify a database flag present in your instance, expand the database flag and modify the value of the existing flag in the Edit database flag section.
    2. Click Done.

    Delete a flag

    1. To delete a database flag from your instance, select a flag and click the delete icon.
    2. Click Done.
  5. Click Update instance.

gcloud

Use the gcloud alloydb instances update command to change the database flags for an instance.

   gcloud alloydb instances update INSTANCE_ID \
   --database-flags FLAGS_LIST \
   --region=REGION_ID \
   --cluster=CLUSTER_ID \
   --project=PROJECT_ID

To apply flag updates more rapidly, include the argument --update-mode=FORCE_APPLY. Because this can temporarily decrease database performance, avoid using this option in a production environment.

   gcloud beta alloydb instances update INSTANCE_ID \
   --database-flags FLAGS_LIST \
   --region=REGION_ID \
   --cluster=CLUSTER_ID \
   --project=PROJECT_ID \
   --update-mode=FORCE_APPLY

Replace the following:

  • INSTANCE_ID: The ID of the instance.
  • FLAGS_LIST: A comma-separated list of one or more database flag specifications. Each specification consists of the name of the flag, an equals sign (=), and the value to assign to the flags. For database flags that do not take values, provide the name of the flag followed by an equals sign (=).
  • REGION_ID: The region where the instance is placed—for example, us-central1.
  • CLUSTER_ID: The ID of the cluster where the instance is placed.
  • PROJECT_ID: The ID of the project where the cluster is placed. undergoing low or zero downtime maintenance cycle, after you modify database flags.

To see the list of an instance's current, manually-set flags, run the following command:

   gcloud alloydb instances describe INSTANCE_ID \
   --region=REGION_ID \
   --cluster=CLUSTER_ID \
   --project=PROJECT_ID