Enable and disable vector embeddings on your instance

This section describes how to configure your Cloud SQL instance to support the storage, indexing, and querying of vector embeddings.

Both Cloud SQL Enterprise edition and Cloud SQL Enterprise Plus edition instances support vector embeddings. All versions of MySQL 8.0.36+ are supported.

Before you begin

Make sure you have the Cloud SQL Admin and Compute Viewer roles on your user account.

For more information, see Roles and permissions.

Enable the database flag for vector embeddings

To turn on support for vector embeddings, you must enable the MySQL database flags.

gcloud sql instances patch INSTANCE_NAME \
 --database-flags=FLAGS

Replace the following:

  • INSTANCE_NAME: the name of the instance you want to enable vector embedding support on.
  • FLAGS: configure the following MySQL flag on your instance:

    • cloudsql_vector: set this flag to on to enable vector embedding storage and vector similarity search support. This flag is off by default. When you configure the flag, your command looks similar to the following:

      gcloud sql instances patch my-instance \
      --database-flags=cloudsql_vector=on
      

      The cloudsql_vector flag is static. After you update the instance with the flag (by turning it on or off), your instance restarts automatically in order for the configuration changes to take effect.

For more information about how to configure database flags for MySQL, see Configure database flags.

Disable vector embeddings

Before you disable vector embeddings on your instance, you must explicitly drop all vector indexes on the instance. To learn how to find a list of vector indexes on the instance, see Monitor vector indexes.

Disabling vector embeddings support prevents you from creating new vector embedding columns and vector indexes. It also prevents you from using the approx_distance function for vector searches. To turn off support for vector embeddings, set the cloudsql_vector flag to off. After you configure this static flag, the instance restarts automatically for the configuration change to take effect.

To disable support for vector embeddings, set the cloudsql_vector flag to off.

For example:

gcloud sql instances patch INSTANCE_NAME \
 --database-flags=cloudsql_vector=off

Replace INSTANCE_NAME with the name of the instance on which you're turning off vector embedding support.

What's next