forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
builtins: add
tenant_span_stats
generator function
Part of: cockroachdb#94332 Part of: cockroachdb#94330 Added new builtin function `tenant_span_stats` that retrieves span statistics for the current tenant. `tenant_span_stats` can be called as: - `crdb_internal.tenant_span_stats()`: returns table span statistics for all of the tenants tables - `crdb_internal.tenant_span_stats(database_id)`: returns table span statistics for the tenant's tables belonging to the specified database id - `crdb_internal.tenant_span_stats(database_id, table_id)`: returns the tenant's table span statistics for the provided table id Release note (sql change): new builtin function `tenants_span_stats`, retrieves the span statistics for the current tenant.
- Loading branch information
Thomas Hardy
committed
Feb 24, 2023
1 parent
4806560
commit bc7d252
Showing
8 changed files
with
291 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# LogicTest: 3node-tenant | ||
|
||
# Create a second database. | ||
statement ok | ||
CREATE DATABASE a | ||
|
||
# Create a table for database. | ||
statement ok | ||
CREATE TABLE a.b (id INT PRIMARY KEY) | ||
|
||
# Create a second table for database. | ||
statement ok | ||
CREATE TABLE a.c (id INT PRIMARY KEY) | ||
|
||
# SELECT * FROM crdb_internal.tenant_span_stats: span stats for all of the tenant's tables. | ||
# Assert the schema. | ||
query IIIIIIR colnames | ||
SELECT * FROM crdb_internal.tenant_span_stats() LIMIT 0 | ||
---- | ||
database_id table_id range_count approximate_disk_bytes live_bytes total_bytes live_percentage | ||
|
||
# SELECT DISTINCT(database_id) FROM crdb_internal.tenant_span_stats: | ||
# Assert that we are collecting span stats for tables across multiple databases. | ||
query I colnames | ||
SELECT DISTINCT(database_id) FROM crdb_internal.tenant_span_stats() | ||
---- | ||
database_id | ||
1 | ||
106 | ||
|
||
# SELECT database_id, table_id FROM crdb_internal.tenant_span_stats(106): | ||
# Assert that we are collecting span stats scoped to the provided database id. | ||
query II colnames | ||
SELECT database_id, table_id FROM crdb_internal.tenant_span_stats(106) | ||
---- | ||
database_id table_id | ||
106 108 | ||
106 109 | ||
|
||
# SELECT database_id, table_id FROM crdb_internal.tenant_span_stats(106, 108): | ||
# Assert that we are collecting span stats scoped to the provided database/table id combo. | ||
query II colnames | ||
SELECT database_id, table_id FROM crdb_internal.tenant_span_stats(106, 108) | ||
---- | ||
database_id table_id | ||
106 108 | ||
|
||
# Assert that we cannot provide an invalid database id. | ||
query error pq: provided database id must be greater than or equal to 1 | ||
SELECT database_id, table_id FROM crdb_internal.tenant_span_stats(0) | ||
|
||
# Assert that we cannot provide an invalid table id. | ||
query error pq: provided table id must be greater than or equal to 1 | ||
SELECT database_id, table_id FROM crdb_internal.tenant_span_stats(1, -1) | ||
|
||
# Assert that we cannot provide an invalid database id with a valid table id. | ||
query error pq: provided database id must be greater than or equal to 1 | ||
SELECT database_id, table_id FROM crdb_internal.tenant_span_stats(-1, 1) | ||
|
||
# SELECT * FROM crdb_internal.tenant_span_stats(1000): | ||
# Assert that we get empty rows for a database id that does not correspond to a database. | ||
query IIIIIIR colnames | ||
SELECT * FROM crdb_internal.tenant_span_stats(1000) | ||
---- | ||
database_id table_id range_count approximate_disk_bytes live_bytes total_bytes live_percentage | ||
|
||
# SELECT * FROM crdb_internal.tenant_span_stats(1, 1000): | ||
# Assert that we get empty rows for a table id that does not correspond to a table. | ||
query IIIIIIR colnames | ||
SELECT * FROM crdb_internal.tenant_span_stats(1, 1000) | ||
---- | ||
database_id table_id range_count approximate_disk_bytes live_bytes total_bytes live_percentage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters