Skip to content

[Improvement] Optimize load database method in JdbcDatabaseOperations #6629

Open
@yuqi1129

Description

@yuqi1129

What would you like to be improved?

load method in JdbcDatabaseOperations will load all databases. if there are a lot of databases, it takes a lot of time.

  @Override
  public JdbcSchema load(String databaseName) throws NoSuchSchemaException {
    // We need to load the database as needed NOT load them all. 
    List<String> allDatabases = listDatabases();
    String dbName =
        allDatabases.stream()
            .filter(db -> db.equals(databaseName))
            .findFirst()
            .orElseThrow(
                () -> new NoSuchSchemaException("Database %s could not be found", databaseName));

    return JdbcSchema.builder()
        .withName(dbName)
        .withProperties(ImmutableMap.of())
        .withAuditInfo(AuditInfo.EMPTY)
        .build();
  }

How should we improve?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementImprovements on everything

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions