Overview of introspection tools

Introspection tools for Cloud Spanner enable you to investigate issues with your database. They consist of a set of built-in tables that you can query to gain more insight about queries, transactions, reads and more. Not sure which tool to use for a particular problem? The following list summarizes each tool and the kinds of questions they can help answer.

Query statistics

To help investigate issues on your database, it is helpful to know which queries are expensive, run frequently or scan a lot of data.

Query statistics are aggregated statistics for successfully completed queries gathered in 1, 10, and 60 minute intervals. The statistics include highest CPU usage, total query execution counts, average latency, most data scanned, and additional basic query statistics. Use these statistics to help identify expensive, frequently run or data-intensive queries.

Read statistics

Read statistics can be used to investigate the most common and most resource-consuming reads on your database using the Cloud Spanner Reads API. These statistics are collected and stored in 3 different time intervals - minute, 10 minutes and an hour. For each time interval, Cloud Spanner tracks the reads that are using the most resources.

Use read statistics to find out the combined resource usage by all reads, find the most CPU consuming reads, and find out how a specific read's frequency changes over time.

Transaction statistics

Transaction statistics can be used to investigate transaction-related issues. For example, you can check for slow-running transactions that might be causing contention or identify changes in transaction shapes that are leading to performance regressions. Each row contains statistics of all transactions executed over the database during 1, 10, and 60 minute intervals.

Operations included in each statistic

In Cloud Spanner there is some overlap between transactions, reads and queries. Therefore, it might not be clear which operations are included when compiling statistics. The following table lists the main operations and their relationship to each statistics table.

Operation Transaction statistics Read statistics Query statistics
Strong read No Yes No
Stale read No Yes No
Single-use transaction1 (reads) No Yes No
Single-use transaction1 (queries) No No Yes
Read-only transaction1 (reads) No Yes No
Read-only transaction1 (queries) No No Yes
Read-write transaction (reads) Yes Yes No
Read-write transactions (queries) Yes No Yes
Read-write transactions (DML2, Mutations3 ) Yes No No


1 Read-related transactions, such as read-only transactions and single-use transactions, are not included in transaction statistics. Only read- write transactions are included in the transaction statistics table.

2 Uncommitted DML operations are not included in transaction statistics.

3 Empty mutations that are effectively no-op, are not included in transaction statistics.