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 vector search functionality using the database flag
To turn on support for storing vector embeddings in your database in
Cloud SQL for MySQL 8.4 and earlier, enable the cloudsql_vector MySQL database flag.
If you're using Cloud SQL for MySQL 9.7 or later, then enable the
cloudsql_vector MySQL database flag to add support for creating vector indexes
and for performing ANN search
gcloud sql instances patch INSTANCE_NAME \
--database-flags=FLAGS
Replace the following:
- INSTANCE_NAME: the name of the instance where you want to enable vector search functionality.
FLAGS: configure the following MySQL flag on your instance:
cloudsql_vector: set this flag toonto enable Cloud SQL vector search functionality. 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=onThe
cloudsql_vectorflag 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 if you're using MySQL 8.4 or earlier. If you're using
MySQL 9.7 or later, you're prevented from creating 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
- Read the overview about vector search on Cloud SQL.
- Learn how to generate vector embeddings.
- Learn how to create vector indexes.
- Learn how to perform searches on vector embeddings.