Skip to content

Commit e17b4f4

Browse files
committed
chore: when table_names exist and are few, then use Database::get_table to further reduce table loading.
1 parent 937a452 commit e17b4f4

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/query/storages/system/src/indexes_table.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ use databend_common_storages_fuse::index::EqVisitor;
4040
use databend_common_storages_fuse::index::ResultRewrite;
4141
use databend_common_storages_fuse::index::Visitor;
4242
use databend_common_storages_fuse::TableContext;
43+
use futures::future::try_join_all;
4344
use log::warn;
4445

4546
use crate::table::AsyncOneBlockSystemTable;
4647
use crate::table::AsyncSystemTable;
4748

49+
const POINT_GET_TABLE_LIMIT: usize = 20;
50+
4851
pub struct IndexesTable {
4952
table_info: TableInfo,
5053
}
@@ -232,7 +235,21 @@ impl IndexesTable {
232235
continue;
233236
}
234237
}
235-
let tables = match catalog.list_tables(&tenant, db_name).await {
238+
let result = match (
239+
table_names,
240+
table_names.iter().len() <= POINT_GET_TABLE_LIMIT,
241+
) {
242+
(Some(table_names), true) => {
243+
try_join_all(
244+
table_names
245+
.iter()
246+
.map(|table_name| db.get_table(table_name)),
247+
)
248+
.await
249+
}
250+
_ => catalog.list_tables(&tenant, db_name).await,
251+
};
252+
let tables = match result {
236253
Ok(tables) => tables,
237254
Err(err) => {
238255
let msg = format!("Failed to list tables in database: {}, {}", db_name, err);

0 commit comments

Comments
 (0)