@@ -709,7 +709,7 @@ CREATE TABLE crdb_internal.pg_catalog_table_is_implemented (
709
709
name STRING NOT NULL,
710
710
implemented BOOL
711
711
)` ,
712
- generator : func (ctx context.Context , p * planner , dbDesc catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
712
+ generator : func (ctx context.Context , p * planner , dbDesc catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
713
713
row := make (tree.Datums , 2 )
714
714
worker := func (ctx context.Context , pusher rowPusher ) error {
715
715
addDesc := func (table * virtualDefEntry , dbName tree.Datum , scName string ) error {
@@ -3852,7 +3852,7 @@ CREATE TABLE crdb_internal.table_columns (
3852
3852
hidden BOOL NOT NULL
3853
3853
)
3854
3854
` ,
3855
- generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
3855
+ generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
3856
3856
const numDatums = 8
3857
3857
row := make (tree.Datums , numDatums )
3858
3858
worker := func (ctx context.Context , pusher rowPusher ) error {
@@ -3921,7 +3921,7 @@ CREATE TABLE crdb_internal.table_indexes (
3921
3921
create_statement STRING NOT NULL
3922
3922
)
3923
3923
` ,
3924
- generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
3924
+ generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
3925
3925
primary := tree .NewDString ("primary" )
3926
3926
secondary := tree .NewDString ("secondary" )
3927
3927
const numDatums = 13
@@ -4490,7 +4490,7 @@ CREATE TABLE crdb_internal.ranges_no_leases (
4490
4490
)
4491
4491
` ,
4492
4492
resultColumns : colinfo .RangesNoLeases ,
4493
- generator : func (ctx context.Context , p * planner , _ catalog.DatabaseDescriptor , _ * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
4493
+ generator : func (ctx context.Context , p * planner , _ catalog.DatabaseDescriptor , limit int64 , _ * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
4494
4494
hasAdmin , err := p .HasAdminRole (ctx )
4495
4495
if err != nil {
4496
4496
return nil , nil , err
@@ -4525,7 +4525,11 @@ CREATE TABLE crdb_internal.ranges_no_leases (
4525
4525
}
4526
4526
4527
4527
execCfg := p .ExecCfg ()
4528
- rangeDescIterator , err := execCfg .RangeDescIteratorFactory .NewIterator (ctx , execCfg .Codec .TenantSpan ())
4528
+ pageSize := int64 (128 )
4529
+ if limit > 0 {
4530
+ pageSize = min (limit , pageSize )
4531
+ }
4532
+ rangeDescIterator , err := execCfg .RangeDescIteratorFactory .NewLazyIterator (ctx , execCfg .Codec .TenantSpan (), int (pageSize ))
4529
4533
if err != nil {
4530
4534
return nil , nil , err
4531
4535
}
@@ -5429,7 +5433,7 @@ CREATE TABLE crdb_internal.partitions (
5429
5433
subzone_id INT -- references a subzone id in the crdb_internal.zones table
5430
5434
)
5431
5435
` ,
5432
- generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
5436
+ generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
5433
5437
dbName := ""
5434
5438
if dbContext != nil {
5435
5439
dbName = dbContext .GetName ()
@@ -6875,7 +6879,7 @@ CREATE TABLE crdb_internal.index_usage_statistics (
6875
6879
total_reads INT NOT NULL,
6876
6880
last_read TIMESTAMPTZ
6877
6881
);` ,
6878
- generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
6882
+ generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
6879
6883
// Perform RPC Fanout.
6880
6884
stats , err :=
6881
6885
p .extendedEvalCtx .SQLStatusServer .IndexUsageStatistics (ctx , & serverpb.IndexUsageStatisticsRequest {})
@@ -6940,7 +6944,7 @@ CREATE TABLE crdb_internal.cluster_statement_statistics (
6940
6944
aggregation_interval INTERVAL NOT NULL,
6941
6945
index_recommendations STRING[] NOT NULL
6942
6946
);` ,
6943
- generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
6947
+ generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
6944
6948
// TODO(azhng): we want to eventually implement memory accounting within the
6945
6949
// RPC handlers. See #69032.
6946
6950
acc := p .Mon ().MakeBoundAccount ()
@@ -7371,7 +7375,7 @@ CREATE TABLE crdb_internal.cluster_transaction_statistics (
7371
7375
statistics JSONB NOT NULL,
7372
7376
aggregation_interval INTERVAL NOT NULL
7373
7377
);` ,
7374
- generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7378
+ generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7375
7379
// TODO(azhng): we want to eventually implement memory accounting within the
7376
7380
// RPC handlers. See #69032.
7377
7381
acc := p .Mon ().MakeBoundAccount ()
@@ -7692,7 +7696,7 @@ CREATE TABLE crdb_internal.transaction_contention_events (
7692
7696
index_name STRING,
7693
7697
contention_type STRING NOT NULL
7694
7698
);` ,
7695
- generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7699
+ generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7696
7700
// Check permission first before making RPC fanout.
7697
7701
// If a user has VIEWACTIVITYREDACTED role option but the user does not
7698
7702
// have the ADMIN role option, then the contending key should be redacted.
@@ -7971,8 +7975,8 @@ type clusterLocksFilters struct {
7971
7975
7972
7976
func genClusterLocksGenerator (
7973
7977
filters clusterLocksFilters ,
7974
- ) func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7975
- return func (ctx context.Context , p * planner , _ catalog.DatabaseDescriptor , _ * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7978
+ ) func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7979
+ return func (ctx context.Context , p * planner , _ catalog.DatabaseDescriptor , _ int64 , _ * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7976
7980
hasAdmin , err := p .HasAdminRole (ctx )
7977
7981
if err != nil {
7978
7982
return nil , nil , err
@@ -8235,7 +8239,7 @@ func populateClusterLocksWithFilter(
8235
8239
) (matched bool , err error ) {
8236
8240
var rowGenerator virtualTableGenerator
8237
8241
generator := genClusterLocksGenerator (filters )
8238
- rowGenerator , _ , err = generator (ctx , p , db , nil /* stopper */ )
8242
+ rowGenerator , _ , err = generator (ctx , p , db , 0 /* limit */ , nil /* stopper */ )
8239
8243
if err != nil {
8240
8244
return false , err
8241
8245
}
0 commit comments