Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
MySQL | PostgreSQL | SQL Server
Nesta página, descrevemos o recomendador de consultas de alta memória para otimização do Cloud SQL, que relata consultas com alta utilização da memória.
Este recomendador relata o texto normalizado das consultas encerradas para evitar erros de falta de memória nas últimas 24 horas. Depois, recomendações vão ser fornecidas
sobre como otimizar essas instâncias e melhorar o desempenho delas. As recomendações são geradas diariamente.
Preços
O recomendador de consultas de alta memória do Cloud SQL está no nível de preçosPadrão.
Antes de começar
Antes de visualizar as recomendações e insights, faça o seguinte:
Clique em Desempenho no card Todas as recomendações.
CLI da gcloud
Para listar recomendações de otimização para consultas com alto uso de memória usando a gcloud CLI, execute o
comando gcloud recommender recommendations list
desta forma:
LOCATION: uma região em que suas instâncias estão localizadas, como us-central1.
API
Para listar recomendações de otimização para consultas com alto uso de memória usando a
API Recommendations, chame o método
recommendations.list
da seguinte maneira:
GET https://recommender.googleapis.com/v1/projects/PROJECT-ID/locations/LOCATION/recommenders/google.cloudsql.instance.PerformanceRecommender/recommendations
Substitua:
PROJECT_ID: o ID do projeto.
LOCATION: uma região em que suas instâncias estão localizadas, como us-central1.
Se o recomendador relatar instâncias com consultas encerradas, ele as listará em uma tabela. Cada linha mostra o nome da instância, uma breve recomendação, o tipo de máquina atual, o tipo de máquina recomendado, o local e a data da última atualização.
Ver insights e recomendações detalhadas
É possível acessar insights e recomendações detalhadas para otimizar consultas com alto uso de memória usando o console do Google Cloud ,
gcloud ou a API Recommender.
Console
Escolha uma destas opções:
Na página Recomendações de desempenho, clique no card Recomendações de desempenho e em Otimizar consultas com muita memória. O painel de recomendações é exibido, contendo insights e recomendações detalhadas para a instância.
Na página Instâncias, clique em Otimizar consultas de alta memória. A lista de instâncias exibe apenas aquelas às quais a recomendação se aplica.
CLI da gcloud
Para acessar insights e recomendações detalhadas para otimizar consultas com alto uso de memória usando gcloud, execute o
comando gcloud recommender insights list
da seguinte maneira:
Para acessar insights e recomendações detalhadas de otimização de consultas com alto uso de memória usando a API Recommendations,
chame o método insights.list
da seguinte maneira:
GET https://recommender.googleapis.com/v1/projects/PROJECT-ID/locations/LOCATION/insightTypes/google.cloudsql.instance.PerformanceInsight/insights
Substitua:
PROJECT_ID: o ID do projeto
LOCATION: uma região, como us-central1.
Aplicar recomendações
Avalie as recomendações com atenção e siga um destes procedimentos:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-09 UTC."],[],[],null,["\u003cbr /\u003e\n\nMySQL \\| PostgreSQL \\| SQL Server\n\n\u003cbr /\u003e\n\nThis page describes the Cloud SQL optimize high memory queries [recommender](/recommender/docs/overview) which reports queries with high memory utilization.\n\nThis recommender reports normalized query text of the queries terminated to prevent out-of-memory errors in the past 24 hours. It then provides recommendations on how to optimize such\ninstances and improve performance. Recommendations are generated daily.\n\nPricing\n\nThe Cloud SQL optimize high memory queries recommender is in the *Standard*\n[Recommender pricing tier](/recommender/pricing).\n\nBefore you begin\n\nBefore you can view recommendations and insights, do the following:\n\n- To get the permissions to view and work with insights and recommendations, ensure that you have the required [Identity and Access Management (IAM) roles](/sql/docs/postgres/project-access-control#roles).\n\n | Tasks | Roles |\n |-----------------------|------------------------------------------------------------------------------------------|\n | View recommendations | One of these roles: `recommender.cloudsqlViewer` or `cloudsql.viewer`. |\n | Apply recommendations | One of these roles: `recommender.cloudsqlAdmin`, `cloudsql.editor`, or `cloudsql.admin`. |\n\n For more information about IAM roles, see [IAM basic and predefined roles reference](/iam/docs/understanding-roles) and [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n-\n\n\n Enable the Recommender API.\n\n\n **Roles required to enable APIs**\n\n\n To enable APIs, you need the Service Usage Admin IAM\n role (`roles/serviceusage.serviceUsageAdmin`), which\n contains the `serviceusage.services.enable` permission. [Learn how to grant\n roles](/iam/docs/granting-changing-revoking-access).\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=recommender.googleapis.com)\n\nList recommendations for optimizing queries with high memory usage\n\nYou can list recommendations for optimizing queries with high memory usage\nusing the Google Cloud console, [gcloud CLI](/sdk/gcloud), or the Recommender API. \n\nConsole\n\nTo list recommendations about instance performance by using the\n\nGoogle Cloud console, follow these steps:\n\n1. Go to the **Cloud SQL Instances** page.\n\n[Go to Cloud SQL Instances](https://console.cloud.google.com/sql/instances)\n\n1. Click **Expand Details** on the **Improve instance health by investigating issues and acting on recommendations** banner.\n\nAlternatively, follow these steps:\n\n1. Go to the **Recommendation Hub** . See also [Find and apply recommendations with the Recommendations](/recommender/docs/recommendation-hub/identify-configuration-problems).\n\n [Go to the Recommendation Hub](https://console.cloud.google.com/home/recommendations/)\n2. Click **Performance** in the **All recommendations** card.\n\ngcloud CLI\n\nTo list optimization recommendations for queries with high memory usage using gcloud CLI, run the\n[`gcloud recommender recommendations list`](/sdk/gcloud/reference/recommender/recommendations/list)\ncommand as follows: \n\n```\ngcloud recommender recommendations list \\\n--project=PROJECT_ID \\\n--location=LOCATION \\\n--recommender=google.cloudsql.instance.PerformanceRecommender \\\n--filter=recommenderSubtype=POSTGRES_OPTIMIZE_HIGH_MEMORY_QUERIES\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: Your project ID.\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: A region where your instances are located, such as `us-central1`.\n\nAPI\n\nTo list optimization recommendations for queries with high memory usage using the\n[Recommendations API](/recommender/docs/using-api), call the\n[`recommendations.list`](/recommender/docs/reference/rest/v1/projects.locations.recommenders.recommendations/list)\nmethod as follows: \n\n```\nGET https://recommender.googleapis.com/v1/projects/PROJECT-ID/locations/LOCATION/recommenders/google.cloudsql.instance.PerformanceRecommender/recommendations\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: Your project ID.\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: A region where your instances are located, such as `us-central1`.\n\nIf the recommender reports instances with terminated queries, it lists them in a table. Each row shows the instance name, a brief recommendation, the current machine type, the recommended machine type, the location, and the last refresh date.\n\nView insights and detailed recommendations\n\nYou can view insights and detailed recommendations for optimizing queries with high memory usage using the Google Cloud console,\n`gcloud`, or the Recommender API. \n\nConsole\n\nDo one of the following:\n\n- On the **Performance Recommendations** page, click **Performance recommendations** card, click **Optimize High Memory Queries**. The recommendation panel appears, which contains insights and detailed recommendations for the instance.\n\n- On the **Instances** page, click **Optimize High Memory Queries**. The list of instances displays only those instances for which the recommendation applies.\n\ngcloud CLI\n\nTo view insights and detailed recommendations for optimizing queries with high memory usage using `gcloud`, run the\n[`gcloud recommender insights list`](/sdk/gcloud/reference/recommender/insights/list)\ncommand as follows: \n\n```\ngcloud recommender insights list \\\n--project=PROJECT_ID \\\n--location=LOCATION \\\n--insight-type=google.cloudsql.instance.PerformanceInsight \\\n--filter=insightSubtype=POSTGRES_HIGH_MEMORY_QUERIES_TERMINATED_TO_PREVENT_OOM\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: Your project ID.\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: A region, such as `us-central1`.\n\nAPI\n\nTo view insights and detailed recommendations for optimizing queries with high memory usage using the [Recommendations API](/recommender/docs/using-api),\ncall the [`insights.list`](/recommender/docs/reference/rest/v1/projects.locations.insightTypes.insights/list)\nmethod as follows: \n\n```\nGET https://recommender.googleapis.com/v1/projects/PROJECT-ID/locations/LOCATION/insightTypes/google.cloudsql.instance.PerformanceInsight/insights\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: Your project ID.\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: A region, such as `us-central1`.\n\nApply recommendations\n\nEvaluate the recommendation carefully and do any of the following:\n\n- For more information, see [Optimize instance high memory usage](/sql/docs/postgres/optimize-high-memory-usage).\n- To dismiss the recommendation so that it's de-emphasized and appears dimmed, click **Dismiss**.\n- To close the panel without applying or dismissing the recommendation, click **Cancel**.\n\nWhat's next\n\n- [Google Cloud recommenders](/recommender/docs/recommenders)\n- [About database observability](/sql/docs/postgres/observability)"]]