To set up Gemini in Databases, perform the steps in this document:
Enable index advisor (only applicable to AlloyDB for PostgreSQL, Cloud SQL for PostgreSQL, and Cloud SQL for MySQL).
Before you begin
To activate Gemini in Databases, you must have the
roles/billing.admin
Identity and Access Management (IAM) role.
Activate Gemini in Databases
To activate Gemini in Databases in a Google Cloud project, you
need to enable the Cloud AI Companion API and grant
roles/cloudaicompanion.user
IAM permissions to users. An administrator or project owner
typically performs these steps.
In the Google Cloud console, go to the Gemini for Google Cloud page.
Click Gemini in Databases.
The Explore Gemini pane is displayed.
Click Get Gemini in Databases.
The Admin for Gemini page is displayed.
Choose the billing account for which you want to activate Gemini in Databases and click Continue to Gemini in Databases page.
The Gemini in Databases page is displayed.
Click Review terms and turn on.
The Turn on Gemini in Databases page is displayed.
Click Purchase to activate Gemini in Databases.
Enable the Recommender API
Enable the Recommender API.
If the Recommender API isn't listed, then it is already enabled for your project.
Enable index advisor
You can enable index advisor for AlloyDB for PostgreSQL, Cloud SQL for MySQL 8.0 instances, and Cloud SQL for PostgreSQL 12 and later instances.
AlloyDB for PostgreSQL
The following steps describe how to enable index advisor for AlloyDB for PostgreSQL.
- Before you enable index advisor, enable enhanced Query Insights on the instance.
In the Google Cloud console, go to the Clusters page.
- From the list of clusters and instances, click an instance.
- Click Query Insights.
- Choose the database and user.
- Click Edit Settings.
- To enable index creation recommendations on a cluster's Query Insights page, select Enable recommendations.
- Save your changes.
For more information about using index advisor in AlloyDB for PostgreSQL, see Use the index advisor with query insights.
Cloud SQL for MySQL
The following steps describe how to enable index advisor for Cloud SQL for MySQL. Index advisor for Cloud SQL for MySQL uses data from MySQL Performance Schema. By default, Cloud SQL enables MySQL Performance Schema on all MySQL 8.0 instances that have more than 15 GB of memory.
- Before you enable index advisor, enable Query Insights on the instance.
- If you already have MySQL Performance Schema enabled on your Cloud SQL for MySQL instances, then to enable index advisor, run the following gcloud CLI command:
- If you don't have MySQL Performance Schema enabled on your Cloud SQL for MySQL instances, then to enable index advisor, run the following gcloud CLI command:
gcloud sql instances patch INSTANCE_NAME \ --database-flags=cloudsql_index_advisor=on
Replace INSTANCE_NAME with the name of your instance.
gcloud sql instances patch INSTANCE_NAME \ --database-flags=cloudsql_index_advisor=on,performance_schema=on
Replace INSTANCE_NAME with the name of your instance.
For more information about configuring flags, see Configure database flags.
Cloud SQL for PostgreSQL
The following steps describe how to enable index advisor for Cloud SQL for PostgreSQL.
- Before you enable index advisor, enable Query Insights on the instance.
- To enable index advisor for Cloud SQL for PostgreSQL instances, run the following Google Cloud CLI command:
gcloud sql instances patch INSTANCE_NAME \ --database-flags=cloudsql.enable_index_advisor=on
Replace INSTANCE_NAME with the name of your instance.
For more information about configuring flags, see Configure database flags.