cockroachdb / cockroachdb/cockroach
o11y: SHOW FULL TABLE SCANS can present misleading results
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
Running on the DRT cluster, I'm seeing some unexpected output from `SHOW FULL TABLE SCANS`. My impression of that statement is that it's intended to be used by users to help optimize performance (as backed up by the [docs page](https://www.cockroachlabs.com/docs/v23.2/show-full-table-scans)). On the DRT cluster, a sample run returns these two statements:
```
root@localhost:26257/application/cct_tpcc> select count, rows_read_avg, query from [show full table scans] where query like '%protected%';
count | rows_read_avg | query
--------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
6 | 1 | WITH current_meta AS (SELECT version, num_records, num_spans, total_bytes FROM system.protected_ts_meta UNION ALL SELECT _ AS version, _ AS num_records, _ AS num_spans, _ AS total_bytes ORDER BY version DESC LIMIT _) SELECT version, num_records, num_spans, total_bytes FROM current_meta
6 | 3 | SELECT id, ts, meta_type, meta, spans, verified, target FROM system.protected_ts_records
```
What's unexpected is that:
1) The two statements are internally driven, and therefore not candidates for optimization by users
2) The average row count for the tables in question is _very_ small
One suggestion, made by the great @smcvey, would be to limit the statement to show rows if `rows_read_avg` is above `sql.defaults.large_full_scan_rows`. Another idea was to add a column which indicates if a given statement is internally driven, so users can ignore those rows. Finally, there was a suggestion to add an `application_name` column, like we have in the SQL Activity view of the DB Console, so that users can more easily debug issues.
These were all proposed in [this](https://cockroachlabs.slack.com/archives/C063CP41TG9/p1707316342463769) thread.
Jira issue: CRDB-35956
Contributor guide
Assessment
This issue has not been assessed yet.