峰值分块 CPU 使用率得分是否为 100%?图表是否随着时间推移出现峰值或上升?如果至少在 10 分钟内未出现持续 100% 的峰值分块 CPU 使用率百分比,则热点可能不是什么问题。如果峰值分块 CPU 使用率百分比在 10 分钟以上的时间内保持在较高水平,您可能需要进一步调查,看看数据库的延迟时间是否高于预期水平。
如果您发现峰值分块 CPU 使用率达到 100% 的持续时间超过 10 分钟,则热点可能需要您的干预。接下来,您可以继续调试之旅,识别数据库中的热分块。
识别有问题的热分块
如需识别可能存在热点的有问题的分块,请参阅 Google Cloud 控制台中的最热的 N 个分块部分,如下所示。
最热的 N 个分块表提供所选时间范围内可能较热的分块概览,并按从最晚到最早的顺序排序。最热的 N 个分块的数量上限为 100。
对于图表,Spanner 会从最热的 N 个分块统计信息表中提取数据,粒度为 1 分钟。图表中每个数据点的值表示 1 分钟时间间隔内的平均值。
下表显示了以下属性:
间隔结束时间:CPU 使用率高峰结束的日期和时间。
分块起始键:分块中行范围的起始键。如果分块起始键是 <begin>,则表示数据库键范围的起始位置。
分块限制键:分块中行范围的限制键。如果限制键是 <end>,则表示数据库键范围的结束位置。
分块 CPU 使用率分数:介于 0 到 100 之间的抽象分数,反映了用户访问单个服务器的分块内的行时所使用的 CPU 数量。使用 CPU 使用率分数有助于评估是否存在热点。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-21。"],[],[],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)"]]