> [!NOTE]
> **Note:** This page contains features related to Cloud SQL editions. For more information about Cloud SQL editions, see [Introduction to Cloud SQL editions](https://docs.cloud.google.com/sql/docs/mysql/editions-intro.md.txt).

<br />

This page provides an overview of data cache and
recommendations for the
workloads that work best when data cache is enabled.
This page also lists the limitations of data cache.

Data cache is an optional feature that stores data pages on high-speed
local solid state drives (SSD) to accelerate query processing.
Data cache extends the
MySQL buffer pool

to use both the memory and the local SSD.


By default,
data cache is enabled automatically when you
[create a Cloud SQL Enterprise Plus edition instance](https://docs.cloud.google.com/sql/docs/mysql/create-instance.md.txt).
If [you upgrade an Cloud SQL Enterprise edition instance to Cloud SQL Enterprise Plus edition](https://docs.cloud.google.com/sql/docs/mysql/upgrade-cloud-sql-instance-to-enterprise-plus-in-place),
then data cache is enabled automatically.

If you don't want to use data cache, then you can
disable data cache when you create the Cloud SQL Enterprise Plus edition instance or when you
upgrade an Cloud SQL Enterprise edition instance to Cloud SQL Enterprise Plus edition.
You can disable data cache for an existing Cloud SQL Enterprise Plus edition instance with
[near-zero downtime](https://docs.cloud.google.com/sql/docs/mysql/availability.md.txt#near-zero-downtime).

To change the data cache setting on your instance,
see [edit an instance](https://docs.cloud.google.com/sql/docs/mysql/edit-instance.md.txt) and

[instance settings](https://docs.cloud.google.com/sql/docs/mysql/instance-settings.md.txt#data-cache).


For instances that have data cache enabled, Cloud SQL
processes read and write requests in the following manner:

- Read request: Cloud SQL prioritizes reading data from the main memory,
  followed by the data cache, and then the instance's storage.
  This allows for the read operations to be processed with the lowest possible latency.

- Write request: Cloud SQL commits the data to the instance's
  storage and simultaneously writes it to the data cache.

If you enable data cache on an instance that uses
[customer-managed encryption keys (CMEK)](https://docs.cloud.google.com/sql/docs/mysql/cmek.md.txt), then
Cloud SQL also encrypts the local SSD used for data cache.

## Recommendations

Data cache provides performance benefits for certain workload types.
We recommend that you enable data cache for the following workload types:

- Workloads where the working dataset doesn't fit in the main memory. Using a data cache delivers maximum performance benefits when the entire working dataset can't fit in the instance's main memory.
  In this scenario, Cloud SQL stores the working dataset in the main memory and the data cache.
  The working dataset is generally smaller than the full dataset.

- Workloads with 16 or more vCPUs. Using a data cache generally provides more performance benefits for workloads with 16 or more vCPUs.

- Workloads with more read operations than write operations. Use a data cache for workloads that are predominantly made up of read operations.

> [!NOTE]
> **Note:** When you switch an instance from Cloud SQL Enterprise Plus edition to Cloud SQL Enterprise edition, data cache is automatically disabled. Switching an instance to Cloud SQL Enterprise edition incurs some downtime.

## Limitations

- When a data cache becomes full, it removes the stored data based on the least recently used analysis to accommodate subsequent updates to the data cache.

<!-- -->

- Data cache isn't supported for the [C4D machine series](https://docs.cloud.google.com/sql/docs/mysql/machine-series-overview.md.txt#c4d). Because data cache is enabled automatically for Cloud SQL Enterprise Plus edition instances, if you provision a Cloud SQL Enterprise Plus edition instance with a C4D machine type (8 vCPUs or larger), you must explicitly disable data cache. For example, for the [gcloud CLI](https://docs.cloud.google.com/sdk/gcloud.md.txt), add the `--no-enable-data-cache` flag to your creation command.
- For the [C4 machine series](https://docs.cloud.google.com/sql/docs/mysql/machine-series-overview.md.txt#c4), data cache isn't supported on the `db-perf-optimized-C4-2` machine type. To use data cache with the C4 machine series, select the `db-perf-optimized-C4-4` or `db-perf-optimized-C4-8` machine type.
- If there's a user- or system-triggered shutdown or restart, then the contents of the data cache are available on restart. However, if the primary instance performs maintenance or encounters an unexpected shutdown, such as in a failover operation, then the contents of the data cache are lost. This can lead to reduced performance while the data cache is repopulated.
- Data cache doesn't store [redo logs](https://dev.mysql.com/doc/refman/8.4/en/en/innodb-redo-log.html) and [binary logs](https://dev.mysql.com/doc/refman/8.0/en/binary-log.html).