Optimize maximum server memory usage
Database instances running with an allocation of memory that's either too low ortoo high might experience performance issues. Instances can sometimes run intoout-of-memory (OOM) issues.
Themax server memory (mb)flag limits the amount of memory that Cloud SQL can allocate for itsinternal pools. You can manually set a value for this flag, or omit the flagand let Cloud SQL manage memory limits for you automatically.
If you don't enable the flag, then Cloud SQL manages the instance'smemory limits for you automatically, based on the size of the RAM for yourinstance.
If you enable the flag and manually set a value for it, and later resize theinstance, then Cloud SQL disables the flag, overrides the valuepreviously given, and automatically manages the memory limits of the instancefor you until a new
max server memory (mb)value is provided.
Insufficient values for the flag can cause performance issues, whileover-allocation can lead to instability, performance degradation, and databasecrashes.
Users are strongly encouraged to let Cloud SQL manage the instance'smemory limits.
For more information, seeSQL Server settings.
Pricing
TheMaximum server memory recommender is in theStandardRecommender pricing tier.
Before you begin
Required roles and permissions
To get the permissions to view and work with insights and recommendations, ensure that you have the requiredIdentity and Access Management (IAM) roles.
| Task | Role |
|---|---|
| View recommendations | recommender.cloudsqlViewer orcloudsql.admin |
| Apply recommendations | cloudsql.editor orcloudsql.admin |
List the recommendations
To list the recommendations, follow these steps:
Console
To list recommendations about instance performance, follow these steps:
- Go to theCloud SQL Instances page.
- On theImprove instance health by investigating issues and acting onrecommendations banner, clickExpand Details.
Alternatively, follow these steps:
Go to theActive Assist. See alsoFind and applyrecommendations with the Recommendations.
In theAll recommendations card, clickPerformance .
gcloud
Run thegcloud recommender recommendations list command as follows:
gcloud recommender recommendations list \--project=PROJECT_ID \--location=LOCATION \--recommender=google.cloudsql.instance.PerformanceRecommender \--filter=RECOMMENDER_SUBTYPE=SQLSERVER_USE_AUTOMATIC_MAX_SERVER_MEMORY_MANAGEMENT
Replace the following:
- PROJECT_ID: your project ID
- LOCATION: a region where your instances are located, such as
us-central1
API
Call therecommendations.list method as follows:
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/recommenders/google.cloudsql.instance.PerformanceRecommender/recommendations
Replace the following:
- PROJECT_ID: your project ID
- LOCATION: a region where your instances are located, such as
us-central1
View insights and detailed recommendations
To view insights and detailed recommendations, follow these steps:
Console
Do one of the following:
On thePerformance Recommendations page, click thePerformancerecommendations card and then clickCreate indexes orreconfigure join settings. The recommendation panel appears, whichcontains insights and detailed recommendations for the instance.
On theInstances page, clickCreate indexes or reconfigure join settings.The list of instances displays only those instances for which therecommendation applies.
gcloud
Run thegcloud recommender insights list command as follows:
gcloud recommender insights list \--project=PROJECT_ID \--location=LOCATION \--insight-type=google.cloudsql.instance.PerformanceInsight \--filter=INSIGHT_SUBTYPE=INSIGHT_SUBTYPE
Replace the following:
- PROJECT_ID: your project ID
- LOCATION: a region where your instances are located, such as
us-central1 - INSIGHT_SUBTYPE: the subtype used to verify whether allocatedmemory is too low or too high. Acceptable values include
SQLSERVER_MAX_SERVER_MEMORY_TOO_LOWandSQLSERVER_MAX_SERVER_MEMORY_TOO_HIGH.
API
Call theinsights.list method as follows:
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/insightTypes/google.cloudsql.instance.PerformanceInsight/insights
Replace the following:
- PROJECT_ID: your project ID
- LOCATION: a region where your instances are located, such as
us-central1
Apply the recommendation
Console
To implement this recommendation, do the following:
Locate the instance with the recommendationServer memory misconfigured.Click the recommendation to open it.
In the recommendation window, clickEdit instance.
In theFlags and parameters section, locate and delete theMax server memory (mb) flag. Removing the flag lets Cloud SQLmanage instance memory limits for you.
What's next
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-11-24 UTC.