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.
sql: new functions
crdb_internal.ranges_in_span
and `crdb_internal.…
…tenant_ranges_per_table` Part of: cockroachdb#94332 Part of: cockroachdb#94330 This PR introduces two new SRFs: `crdb_internal.ranges_in_span(start_key, end_key)` - returns the set of ranges encompassing this span in the form of `(range_id, start_key, end_key)` `crdb_internal.tenant_ranges_per_table()` - returns the tenant's tables, each table row contains the set of ranges encompassing the table, each row takes the form of `(database_name, database_id, table_name, table_id, range_count, range_ids)` The former SRF is a QOL improvement. The latter SRF is intended to be used as a method to retrieve a large number of tables' range data quickly, particularly for the database details page (where we surface the range count of each table). The latter SRF is able to the range ids & range count for ~10,000 tables in ~1.5s. Release note(sql change): introduce two SRFs `crdb_internal.ranges_in_span` and `crdb_internal.tenant_ranges_per_table`
- Loading branch information
Thomas Hardy
committed
Jan 26, 2023
1 parent
6819d87
commit b9f2820
Showing
6 changed files
with
280 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# LogicTest: local | ||
|
||
subtest select_all_ranges_in_span | ||
|
||
# SELECT * FROM crdb_internal.ranges_in_span: all ranges within given span. | ||
# Assert the schema, using 'system.descriptor' table span as parameter. | ||
query ITT colnames | ||
SELECT * FROM crdb_internal.ranges_in_span('\x8b', '\x8c') LIMIT 0 | ||
---- | ||
range_id start_key end_key | ||
|
||
# SELECT * FROM crdb_internal.ranges_in_span: all ranges within given span. | ||
# Assert correct values, using 'system.descriptor' table span as parameter. | ||
query ITT colnames | ||
SELECT range_id, crdb_internal.pretty_key(start_key, -1) as start_key, crdb_internal.pretty_key(end_key, -1) as end_key FROM crdb_internal.ranges_in_span('\x8b', '\x8c') | ||
---- | ||
range_id start_key end_key | ||
7 /Table/3 /Table/4 |
18 changes: 18 additions & 0 deletions
18
pkg/sql/logictest/testdata/logic_test/tenant_ranges_per_table
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,18 @@ | ||
# LogicTest: local | ||
|
||
subtest select_tenant_ranges_per_table | ||
|
||
# SELECT * FROM crdb_internal.tenant_ranges_per_table: all tenant's ranges per table. | ||
# Assert the schema. | ||
query TITIIT colnames | ||
SELECT * FROM crdb_internal.tenant_ranges_in_span() LIMIT 0 | ||
---- | ||
database_name database_id table_name table_id range_count range_ids | ||
|
||
# SELECT * FROM crdb_internal.tenant_ranges_per_table: all tenant's ranges per table. | ||
# Assert correct values. | ||
query TITIIT colnames | ||
SELECT * FROM crdb_internal.tenant_ranges_in_span() LIMIT 1 | ||
---- | ||
database_name database_id table_name table_id range_count range_ids | ||
system 1 descriptor 3 1 {7} |
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
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