Skip to content

Commit

Permalink
Merge #132604
Browse files Browse the repository at this point in the history
132604: cluster-ui: add index count col to db details r=xinhaoz a=xinhaoz

This commit adds the 'Indexes' column to the v2 db
details page, which lists the table's index count.

Additionally, we add 1 to the index count retrieved
in the table metadata batch iterator to account for
the primary index. This value previously represented
only secondary indexes.

Epic: CRDB-37558

Release note: None

Co-authored-by: Xin Hao Zhang <[email protected]>
  • Loading branch information
craig[bot] and xinhaoz committed Oct 14, 2024
2 parents 71c6071 + f507690 commit 12200c7
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 181 deletions.
7 changes: 4 additions & 3 deletions pkg/sql/tablemetadatacache/table_metadata_batch_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
schemaIDIdx
schemaNameIdx
columnCountIdx
indexCountIdx
secondaryIndexCountIdx
tableTypeIdx
autoStatsEnabledIdx
statsLastUpdatedIdx
Expand Down Expand Up @@ -162,8 +162,9 @@ func (batchIter *tableMetadataBatchIterator) fetchNextBatch(ctx context.Context)
schemaID: int(tree.MustBeDInt(row[schemaIDIdx])),
schemaName: string(tree.MustBeDString(row[schemaNameIdx])),
columnCount: int(tree.MustBeDInt(row[columnCountIdx])),
indexCount: int(tree.MustBeDInt(row[indexCountIdx])),
tableType: string(tree.MustBeDString(row[tableTypeIdx])),
// Add 1 to the index count to account for the primary index.
indexCount: int(tree.MustBeDInt(row[secondaryIndexCountIdx])) + 1,
tableType: string(tree.MustBeDString(row[tableTypeIdx])),
}

if row[autoStatsEnabledIdx] != tree.DNull {
Expand Down
128 changes: 64 additions & 64 deletions pkg/sql/tablemetadatacache/testdata/update_table_metadata
Original file line number Diff line number Diff line change
Expand Up @@ -72,70 +72,70 @@ SELECT
FROM system.table_metadata
ORDER BY (db_name, table_name)
----
autostats_disabled defaultdb public 100 107 2 0 TABLE false {1} 1 2021-01-07 06:13:20 +0000 UTC
autostats_enabled defaultdb public 100 106 2 0 TABLE true {1} 1 2021-01-07 06:13:20 +0000 UTC
mymaterializedview defaultdb public 100 109 4 0 MATERIALIZED_VIEW null {1} 1 2021-01-07 06:13:20 +0000 UTC
myseq defaultdb public 100 110 1 0 SEQUENCE null {1} 1 2021-01-07 06:13:20 +0000 UTC
mytable defaultdb public 100 104 3 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
mytable2 defaultdb public 100 105 4 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
myview defaultdb public 100 108 3 0 VIEW null {1} 1 2021-01-07 06:13:20 +0000 UTC
comments system public 1 24 4 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
database_role_settings system public 1 44 4 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
descriptor system public 1 3 2 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
descriptor_id_seq system public 1 7 1 0 SEQUENCE null {1} 1 2021-01-07 06:13:20 +0000 UTC
eventlog system public 1 12 6 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
external_connections system public 1 53 7 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
job_info system public 1 54 4 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
jobs system public 1 15 12 4 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
join_tokens system public 1 41 3 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
lease system public 1 11 5 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
locations system public 1 21 4 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
migrations system public 1 40 5 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
mvcc_statistics system public 1 64 6 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
namespace system public 1 30 4 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
privileges system public 1 52 5 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
protected_ts_meta system public 1 31 5 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
protected_ts_records system public 1 32 8 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
rangelog system public 1 13 7 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
region_liveness system public 1 9 2 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
replication_constraint_stats system public 1 25 7 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
replication_critical_localities system public 1 26 5 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
replication_stats system public 1 27 7 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
reports_meta system public 1 28 2 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
role_id_seq system public 1 48 1 0 SEQUENCE null {1} 1 2021-01-07 06:13:20 +0000 UTC
role_members system public 1 23 5 5 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
role_options system public 1 33 4 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
scheduled_jobs system public 1 37 10 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
settings system public 1 6 4 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_configurations system public 1 47 3 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_count system public 1 51 2 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_stats_buckets system public 1 56 5 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_stats_samples system public 1 57 2 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_stats_tenant_boundaries system public 1 58 2 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_stats_unique_keys system public 1 55 2 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
sql_instances system public 1 46 8 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
sqlliveness system public 1 39 3 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_activity system public 1 61 17 7 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_bundle_chunks system public 1 34 3 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_diagnostics system public 1 36 7 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_diagnostics_requests system public 1 35 11 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_execution_insights system public 1 66 29 4 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_statistics system public 1 42 19 8 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
table_metadata system public 1 67 18 10 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
table_statistics system public 1 20 12 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
task_payloads system public 1 59 8 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
tenant_id_seq system public 1 63 1 0 SEQUENCE null {1} 1 2021-01-07 06:13:20 +0000 UTC
tenant_settings system public 1 50 6 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
tenant_tasks system public 1 60 7 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
tenant_usage system public 1 45 14 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
tenants system public 1 8 6 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
transaction_activity system public 1 62 14 7 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
transaction_execution_insights system public 1 65 23 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
transaction_statistics system public 1 43 14 7 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
ui system public 1 14 3 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
users system public 1 4 4 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
web_sessions system public 1 19 9 4 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
zones system public 1 5 2 0 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
autostats_disabled defaultdb public 100 107 2 1 TABLE false {1} 1 2021-01-07 06:13:20 +0000 UTC
autostats_enabled defaultdb public 100 106 2 1 TABLE true {1} 1 2021-01-07 06:13:20 +0000 UTC
mymaterializedview defaultdb public 100 109 4 1 MATERIALIZED_VIEW null {1} 1 2021-01-07 06:13:20 +0000 UTC
myseq defaultdb public 100 110 1 1 SEQUENCE null {1} 1 2021-01-07 06:13:20 +0000 UTC
mytable defaultdb public 100 104 3 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
mytable2 defaultdb public 100 105 4 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
myview defaultdb public 100 108 3 1 VIEW null {1} 1 2021-01-07 06:13:20 +0000 UTC
comments system public 1 24 4 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
database_role_settings system public 1 44 4 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
descriptor system public 1 3 2 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
descriptor_id_seq system public 1 7 1 1 SEQUENCE null {1} 1 2021-01-07 06:13:20 +0000 UTC
eventlog system public 1 12 6 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
external_connections system public 1 53 7 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
job_info system public 1 54 4 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
jobs system public 1 15 12 5 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
join_tokens system public 1 41 3 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
lease system public 1 11 5 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
locations system public 1 21 4 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
migrations system public 1 40 5 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
mvcc_statistics system public 1 64 6 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
namespace system public 1 30 4 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
privileges system public 1 52 5 3 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
protected_ts_meta system public 1 31 5 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
protected_ts_records system public 1 32 8 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
rangelog system public 1 13 7 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
region_liveness system public 1 9 2 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
replication_constraint_stats system public 1 25 7 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
replication_critical_localities system public 1 26 5 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
replication_stats system public 1 27 7 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
reports_meta system public 1 28 2 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
role_id_seq system public 1 48 1 1 SEQUENCE null {1} 1 2021-01-07 06:13:20 +0000 UTC
role_members system public 1 23 5 6 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
role_options system public 1 33 4 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
scheduled_jobs system public 1 37 10 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
settings system public 1 6 4 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_configurations system public 1 47 3 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_count system public 1 51 2 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_stats_buckets system public 1 56 5 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_stats_samples system public 1 57 2 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_stats_tenant_boundaries system public 1 58 2 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
span_stats_unique_keys system public 1 55 2 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
sql_instances system public 1 46 8 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
sqlliveness system public 1 39 3 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_activity system public 1 61 17 8 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_bundle_chunks system public 1 34 3 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_diagnostics system public 1 36 7 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_diagnostics_requests system public 1 35 11 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_execution_insights system public 1 66 29 5 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
statement_statistics system public 1 42 19 9 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
table_metadata system public 1 67 18 11 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
table_statistics system public 1 20 12 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
task_payloads system public 1 59 8 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
tenant_id_seq system public 1 63 1 1 SEQUENCE null {1} 1 2021-01-07 06:13:20 +0000 UTC
tenant_settings system public 1 50 6 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
tenant_tasks system public 1 60 7 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
tenant_usage system public 1 45 14 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
tenants system public 1 8 6 3 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
transaction_activity system public 1 62 14 8 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
transaction_execution_insights system public 1 65 23 3 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
transaction_statistics system public 1 43 14 8 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
ui system public 1 14 3 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
users system public 1 4 4 2 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
web_sessions system public 1 19 9 5 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC
zones system public 1 5 2 1 TABLE null {1} 1 2021-01-07 06:13:20 +0000 UTC

query
SELECT count(*) FROM system.table_metadata WHERE perc_live_data > 1
Expand Down
Loading

0 comments on commit 12200c7

Please sign in to comment.