最高的分割 CPU 用量分數是否為 100%?圖表是否出現尖峰,或隨著時間推移而升高?如果持續 10 分鐘以上,您都未看到 CPU 使用率達到 100% 的尖峰值,則熱點可能不是問題。如果分割的 CPU 使用率百分比在尖峰時段偏高,且持續超過 10 分鐘,建議您進一步調查,看看資料庫的延遲時間是否高於預期。
如果分割 CPU 使用率百分比在 10 分鐘內達到 100% 尖峰值,則可能需要介入處理資源使用率不均的情況。接下來,您可以繼續進行偵錯,找出資料庫中資源使用率不均的分割。
找出有問題的熱分割
如要找出可能出現熱點的問題分割,請參閱 Google Cloud 控制台中的「TopN splits」(前 N 個分割)部分,如下所示。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-03 (世界標準時間)。"],[],[],null,["# Find hotspots in your database\n\nThis page describes how to use the Hotspot insights dashboard to\ndetect hotspots in your Spanner database.\n\nHotspot insights overview\n-------------------------\n\nHotspots cause latency in your Spanner database. The\nHotspot insights dashboard helps you detect the splits affected by\nhotspots. Use the following steps to determine if hotspots are causing latency\nand if it is, how to resolve the issue:\n\n1. [Open the dashboard.](/spanner/docs/find-hotspots-in-database#dashboard)\n2. [Determine whether hotspots needs your intervention.](#determine-intervention)\n3. [Identify problematic hot splits.](#identify-hot-splits)\n\nHotspot insights is available in single-region, multi-region, and\ndual-region configurations.\n\nPricing\n-------\n\nThere is no additional cost for Hotspot insights.\n\nData retention\n--------------\n\nThe maximum data retention for the Hotspot insights chart and table\nis 6 hours.\n\nFor the hottest splits table, data is taken from the\n`SPANNER_SYS.SPLIT_STATS_TOP_MINUTE` table, which has a maximum retention\nof 6 hours. For more information, see\n[Data retention](/spanner/docs/introspection/hot-split-statistics#data_retention_for_the_hot_split_statistics).\n\nRequired roles\n--------------\n\nYou might need different IAM roles and permissions, depending\non whether you are an IAM user or a fine-grained access control user.\n\n### Identity and Access Management (IAM) user\n\n\nTo get the permissions that\nyou need to view the **Hotspot insights** page,\n\nask your administrator to grant you the\nfollowing IAM roles on the instance:\n\n- [Cloud Spanner Viewer](/iam/docs/roles-permissions/spanner#spanner.viewer) (`roles/spanner.viewer`)\n- [Cloud Spanner Database Reader](/iam/docs/roles-permissions/spanner#spanner.databaseReader) (`roles/spanner.databaseReader`)\n\n\nThe following permissions in the [Cloud Spanner Database Reader](/iam/docs/understanding-roles#spanner.databaseReader) (`roles/spanner.databaseReader`) role are required to view the **Hotspot insights** page:\n\n\u003cbr /\u003e\n\n- `spanner.databases.beginReadOnlyTransaction`\n- `spanner.databases.select`\n- `spanner.sessions.create`\n\n### Fine-grained access control user\n\nIf you are a fine-grained access control user, ensure that you:\n\n- Have the [Cloud Spanner Viewer](/iam/docs/understanding-roles#spanner.viewer) (`roles/spanner.viewer`)\n- Have fine-grained access control privileges and are granted the `spanner_sys_reader` system role or one of its member roles.\n- Select the `spanner_sys_reader` or a member role as your current system role on the database **Overview** page.\n\n| **Note:** If you already have an IAM database-level permission, such as `spanner.databases.select`, the Google Cloud console assumes that you are an IAM user. You can't select the `spanner_sys_reader` or a member role on the database overview page as an IAM user.\n\nFor more information, see [fine-grained access control overview](/spanner/docs/fgac-about) and\n[Fine-grained access control system roles](/spanner/docs/fgac-system-roles).\n\nOpen the Hotspot insights dashboard\n-----------------------------------\n\nThe **Hotspot insights** dashboard shows the peak split CPU usage\npercentage. This metric is an abstract percentage of 0 to 100 that reflects the\namount of CPU used when rows within a split are accessed.\n\nTo view the **Hotspot insights** dashboard for a database, do the\nfollowing:\n\n1. In Google Cloud console, open the **Spanner** page.\n\n [Go to Spanner](https://console.cloud.google.com/spanner)\n2. Select an instance from the list.\n\n3. In the navigation menu, click the **Hotspot insights**\n tab.\n\n4. In the **database** field, select a database from the list. The dashboard\n shows the peak split CPU usage score for the database.\n\nThe areas of the dashboard include:\n\n- **Peak split CPU usage score** graph: a higher CPU usage score (such as near 100) indicates that the split is hot and very likely causing a hotspot on the server compared to lower scores.\n- **Database field**: filters the hot splits information on a specific database or all databases.\n- **Time range filter**: filters the peak splits CPU usage by 1-minute increments up to a total of 6 hours.\n- **TopN splits table**: displays the list of top splits sorted by split CPU usage scores.\n\nDetermine if hotspots need intervention\n---------------------------------------\n\nIf you see a spike or an elevation in the graph that corresponds to the overall\nlatency and a persistent high peak split CPU usage score, then you might need to\ninvestigate further.\n\nReview the graph to explore these questions:\n\n- **Which database is experiencing the latency degradation?** Select different\n databases from the **Databases** list to find the databases with the highest\n latency. To find out which database has the highest load, you can also\n review the [**Latency** chart](/spanner/docs/latency-metrics#overview) for\n databases in the Google Cloud console.\n\n- **Is the latency high?** Is the latency high as compared to the expected\n latency for the workload? Is the graph spiking or becoming more elevated\n over time? If you don't see high latency, then hotspots aren't a problem.\n\n- **Is the high peak split CPU usage score at 100%?** Is the graph spiking or\n becoming more elevated over time? If you don't see persistent 100% peak\n split CPU usage percentages for at least 10 minutes, then hotspots might not\n be a problem.\n If the peak split CPU usage percentage is high for longer than 10 minutes,\n then you might want to investigate further to see if the database has higher\n than expected latency levels.\n\nIf you see 100% peak split CPU usage percentages for longer than 10 minutes,\nthen hotspots might need your intervention. Next, you can continue the debugging\njourney by identifying the hot splits in your database.\n\nIdentify problematic hot splits\n-------------------------------\n\nTo identify a potentially problematic split that has hotspots, see the **TopN\nsplits** section in the Google Cloud console, as shown in the following.\n\nThe **TopN splits** table provides an overview of the splits that might be\nhot during the chosen time window, sorted from latest to earliest. The number of\nTopN splits is limited to 100.\n\nFor the graphs, Spanner fetches data from the TopN splits\nstatistics table, with a granularity of one minute. The value\nfor each data point in the graphs represents the average value over an interval\nof one minute.\n\nThe table shows the following properties:\n\n- **Interval end**: the date and time when the high peak CPU usage ends.\n- **Split start**: the starting key of the range of rows in the split. If the split start is \\\u003cbegin\\\u003e, it indicates the beginning of the key range of the database.\n- **Split limit**: the limit key of the range of rows in the split. If the limit key is \\\u003cend\\\u003e, it indicates the end of the key range of the database.\n- **Split CPU usage score**: an abstract score of between 0 and 100 that reflects the amount of CPU used by accesses to the rows within the split on a single server. Use the CPU usage score to help evaluate whether you have hotspots.\n- **Affected tables**: the tables whose rows might be in the split.\n\nWhat's next\n-----------\n\n- Learn about [Split hotspot statistics](/spanner/docs/introspection/hot-split-statistics)"]]