[[["易于理解","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-09-05。"],[],[],null,["# Test and tune your schema and application performance\n\nPerformance tuning is an iterative process in which you evaluate metrics like\nCPU utilization and latency, adjust your schema\nand application to improve performance, and test again.\n\nFor example, in your schema, you might add or change an index, or change a\nprimary key. In your application, you might batch writes, or you might merge or\nmodify your queries.\n\nFor production traffic in particular, performance tuning is important to help\navoid surprises. Performance tuning is more effective the closer the setup is to\nlive production traffic throughput and data sizes.\n\nTo test and tune your schema and application performance, follow these steps:\n\n1. Upload a subset of your data into a Spanner database. You can use the [BigQuery reverse ETL workflow](/bigquery/docs/export-to-spanner) to load the sample data. For more information, see [Load sample data](/spanner/docs/load-sample-data).\n2. Point the application to Spanner.\n3. Verify the database consistency by checking for basic flows.\n4. Verify that performance meets your expectations by performing load tests on your application. For help identifying and optimizing your most expensive queries, see [Detect query performance issues with query insights](/spanner/docs/using-query-insights). In particular, the following factors can contribute to suboptimal query performance:\n 1. **Inefficient queries** : For information about writing efficient SQL queries, see [SQL best practices](/spanner/docs/sql-best-practices).\n 2. **High CPU utilization** : For more information, see [Investigate high CPU utilization](/spanner/docs/introspection/investigate-cpu-utilization).\n 3. **Locking** : To reduce bottlenecks caused by transaction locking, see [Identify transactions that might cause high latencies](/spanner/docs/use-lock-and-transaction-insights).\n 4. **Inefficient schema design** : If the schema isn't designed well, query optimization isn't very useful. For more information about designing good schemas, see [Schema design best practices](/spanner/docs/schema-design).\n 5. **Hotspots** : Hotspots in Spanner limit write throughput, especially for high-QPS applications. To identify hotspots or schema design issues, check the [Key\n Visualizer](/spanner/docs/key-visualizer) statistics from the Google Cloud console. For more information about avoiding hotspots, see [Choose a primary key to prevent hotspots](/spanner/docs/schema-design#primary-key-prevent-hotspots).\n5. If you modify schema or indexes, repeat database consistency and performance testing until you achieve satisfactory results.\n\nFor more information about fine-tuning your database performance, contact\n[Spanner support](/spanner/docs/getting-support)."]]