Skip to content

Commit

Permalink
[core] Improve the performance of show tables (#4592)
Browse files Browse the repository at this point in the history
  • Loading branch information
xleoken authored Nov 26, 2024
1 parent 408b78d commit 139b5a7
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,16 @@ protected List<String> listTablesInFileSystem(Path databasePath) throws IOExcept
}

protected boolean tableExistsInFileSystem(Path tablePath, String branchName) {
return !new SchemaManager(fileIO, tablePath, branchName).listAllIds().isEmpty();
SchemaManager schemaManager = new SchemaManager(fileIO, tablePath, branchName);

// in order to improve the performance, check the schema-0 firstly.
boolean schemaZeroExists = schemaManager.schemaExists(0);
if (schemaZeroExists) {
return true;
} else {
// if schema-0 not exists, fallback to check other schemas
return !schemaManager.listAllIds().isEmpty();
}
}

public Optional<TableSchema> tableSchemaInFileSystem(Path tablePath, String branchName) {
Expand Down

0 comments on commit 139b5a7

Please sign in to comment.