Test and tune your schema and application performance Stay organized with collections Save and categorize content based on your preferences.
Performance tuning is an iterative process in which you evaluate metrics likeCPU utilization and latency, adjust your schemaand application to improve performance, and test again.
For example, in your schema, you might add or change an index, or change aprimary key. In your application, you might batch writes, or you might merge ormodify your queries.
For production traffic in particular, performance tuning is important to helpavoid surprises. Performance tuning is more effective the closer the setup is tolive production traffic throughput and data sizes.
To test and tune your schema and application performance, follow these steps:
- Upload a subset of your data into a Spanner database.You can use theBigQuery reverse ETL workflowto load the sample data. For more information, seeLoad sample data.
- Point the application to Spanner.
- Verify the database consistency by checking for basic flows.
- Verify that performance meets your expectations by performing load testson your application. For help identifying and optimizing your mostexpensive queries, seeDetect query performance issues with query insights.In particular, the following factors can contribute to suboptimal queryperformance:
- Inefficient queries: For information about writing efficient SQLqueries, seeSQL best practices.
- High CPU utilization: For more information, seeInvestigate high CPU utilization.
- Locking: To reduce bottlenecks caused by transaction locking,seeIdentify transactions that might cause high latencies.
- Inefficient schema design: If the schema isn't designed well, queryoptimization isn't very useful. For more information about designinggood schemas, seeSchema design best practices.
- Hotspots: Hotspots in Spanner limit write throughput,especially for high-QPS applications. To identify hotspots orschema design issues, check theKeyVisualizerstatistics from the Google Cloud console. For more information aboutavoiding hotspots, seeChoose a primary key to prevent hotspots.
- If you modify schema or indexes, repeat database consistency and performancetesting until you achieve satisfactory results.
For more information about fine-tuning your database performance, contactSpanner support.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.