本頁說明如何管理臨時資料表的數量。這項建議稱為「調整臨時資料表設定」。
這項建議工具每天都會分析磁碟上建立的臨時資料表數量,並與臨時資料表總數進行比較。如果磁碟上建立的臨時資料表數量超過資料表總數的 20%,這項建議工具會建議您採取下列任一做法:
提高
tmp_table_size旗標或max_heap_table_size旗標的值,或同時提高這兩個旗標的值。如果
max_heap_tmp_table_size和tmp_table_size的值不相等,請將較小的值調高至與較大的值相同。如果
max_heap_tmp_table_size和tmp_table_size的值相同,請將兩者都調高。
如要進一步瞭解如何提高 tmp_table_size 的值,請參閱 tmp_table_size。
定價
「調整臨時資料表設定」建議工具屬於標準建議工具定價級別。
事前準備
必要角色和權限
如要取得查看及使用洞察和建議的權限,請確認您具備必要的 Identity and Access Management (IAM) 角色。
| 工作 | 角色 |
|---|---|
| 查看建議 |
recommender.cloudsqlViewer 或 cloudsql.admin |
| 套用建議 |
cloudsql.editor 或 cloudsql.admin
|
列出建議
如要列出建議,請按照下列步驟操作:
控制台
如要列出執行個體效能的建議,請按照下列步驟操作:
- 前往「Cloud SQL 執行個體」頁面。
前往「Cloud SQL Instances」(Cloud SQL 執行個體) 頁面
- 在「Improve instance health by investigating issues and acting on recommendations」(調查問題並按照建議採取行動,增進執行個體健康) 橫幅中,按一下「Expand Details」(展開詳細資料)。
或者,請按照下列步驟操作:
前往「Active Assist」。另請參閱「使用建議功能尋找及套用建議」。
在「所有建議」資訊卡中,按一下「成效」。
gcloud
執行 gcloud recommender recommendations list 指令,如下所示:
gcloud recommender recommendations list \ --project=PROJECT_ID \ --location=LOCATION \ --recommender=google.cloudsql.instance.PerformanceRecommender \ --filter=recommenderSubtype=MYSQL_RECONFIG_TMP_TABLES
更改下列內容:
- PROJECT_ID:專案 ID
- LOCATION:執行個體所在的區域,例如
us-central1
API
呼叫 recommendations.list 方法,如下所示:
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/recommenders/google.cloudsql.instance.PerformanceRecommender/recommendations
更改下列內容:
- PROJECT_ID:專案 ID
- LOCATION:執行個體所在的區域,例如
us-central1
查看洞察資料和詳細建議
如要查看洞察資料和詳細建議,請按照下列步驟操作:
控制台
執行下列其中一個步驟:
在「Performance Recommendations」(效能建議) 頁面中,按一下「Performance recommendations」(效能建議) 資訊卡,然後點選「Reconfigure temp table settings」(重新設定臨時資料表設定)。系統會顯示建議面板,其中包含執行個體的深入分析和詳細建議。
在「執行個體」頁面,點選「重新設定臨時資料表設定」。執行個體清單只會顯示適用建議的執行個體。
gcloud
執行 gcloud recommender insights list 指令,如下所示:
gcloud recommender insights list \ --project=PROJECT_ID \ --location=LOCATION \ --insight-type=google.cloudsql.instance.PerformanceInsight \ --filter=insightSubtype=INSIGHT_SUBTYPE
更改下列內容:
- PROJECT_ID:專案 ID
- LOCATION:執行個體所在的區域,例如
us-central1 - INSIGHT_SUBTYPE:將這個參數設為下列其中一項:
MYSQL_HIGH_NUMBER_OF_TMP_TABLE_ON_DISK_TMP_TABLE:顯示執行個體磁碟上臨時資料表總數的洞察MYSQL_HIGH_NUMBER_OF_TMP_TABLE_ON_DISK_MAX_HEAP:顯示執行個體磁碟上,使用者建立的臨時資料表總數洞察資料
API
呼叫 insights.list 方法,如下所示:
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/insightTypes/google.cloudsql.instance.PerformanceInsight/insights
更改下列內容:
- PROJECT_ID:專案 ID
- LOCATION:執行個體所在的區域,例如
us-central1
套用最佳化建議
如要採行這項建議,請執行下列任一操作:
如果
max_heap_tmp_table_size和tmp_table_size旗標的值不相等,請將較小的值調高至與較大的值相同。如果
max_heap_tmp_table_size和tmp_table_size旗標的值相同,請將兩者都調高。