Set up Gemini in Databases

To set up Gemini in Databases, perform the steps in this document:

  1. Activate Gemini in Databases.

  2. Enable the Recommender API.

  3. 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

  1. In the Google Cloud console, go to the Gemini for Google Cloud page.

    Gemini for Google Cloud

  2. Click Gemini in Databases.

    The Explore Gemini pane is displayed.

  3. Click Get Gemini in Databases.

    The Admin for Gemini page is displayed.

  4. Choose the billing account for which you want to activate Gemini in Databases and click Continue to Admin for Gemini page.

    The Gemini in Databases page is displayed.

  5. Click Review terms and turn on.

    The Turn on Gemini in Databases page is displayed.

  6. Click Purchase to activate Gemini in Databases.

Enable the Recommender API

Enable the Recommender API.

Enable the 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.

  1. Before you enable index advisor, enable enhanced Query Insights on the instance.
  2. In the Google Cloud console, go to the Clusters page.

    Go to Clusters

  3. From the list of clusters and instances, click an instance.
  4. Click Query Insights.
  5. Choose the database and user.
  6. Click Edit Settings.
  7. To enable index creation recommendations on a cluster's Query Insights page, select Enable recommendations.
  8. 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.

  1. Before you enable index advisor, enable Query Insights on the instance.
  2. 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:
  3. gcloud sql instances patch INSTANCE_NAME \
        --database-flags=cloudsql_index_advisor=on
    

    Replace INSTANCE_NAME with the name of your instance.

  4. 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:
  5. 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.

  1. Before you enable index advisor, enable Query Insights on the instance.
  2. To enable index advisor for Cloud SQL for PostgreSQL instances, run the following Google Cloud CLI command:
  3. 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.