Database / Google Spanner Database Interview questions
How do you troubleshoot high latency in Spanner queries?
Latency issues in Spanner usually fall into a few diagnosable buckets, so troubleshooting starts with narrowing down which one applies.
- Check Cloud Monitoring's split-level metrics for CPU and lock-wait concentration, which points to a hotspot rather than a query problem.
- Run EXPLAIN / query stats to see whether the query is hitting a full table scan instead of using an index.
- Inspect lock wait and transaction abort metrics - frequent aborts usually mean contention on the same rows from concurrent read-write transactions.
- Review read type - a strong read that could tolerate staleness is paying an unnecessary latency cost versus bounded staleness.
- Check for cross-region round trips - a client in one region hitting a leader replica in another adds fixed network latency that no query tuning fixes.
Isolating which layer, schema, query plan, contention, or topology, is responsible avoids wasted effort tuning a query when the real cause is a hot key or a distant leader replica.
More Related questions...