darkaquarius opened a new issue #11250:
URL: https://github.com/apache/shardingsphere/issues/11250


   There are 7000+ tables in my database, most of them are single tables.
   When the application starts, it will scan all the tables, and each table 
will scan the table structure, causing my program to take 10 minutes.Can we 
optimize the startup speed?
   
   ShardingRule:
   ```
   public ShardingRule(final ShardingRuleConfiguration config, final 
DatabaseType databaseType, final Map<String, DataSource> dataSourceMap) {
            ......
           singleTableRules = SingleTableRuleLoader.load(databaseType, 
dataSourceMap, getExcludedTables());
            ......
       }
   ```
   
   FederateSchemaMetadata
   ```
   private void initTables(final ShardingSphereMetaData metaData) throws 
SQLException {
           ......
           Map<String, Collection<DataNode>> tableDataNodes = 
getTableDataNodes(dataNodeRules);
           ......
          for (Entry<String, Collection<DataNode>> entry : 
tableDataNodes.entrySet()) {
             ...... 
         }
       }
   ```
   
   ShardingRule:
   ```
   @Override
       public Map<String, Collection<DataNode>> getAllDataNodes() {
           ......
           singleTableRules.forEach((key, value) -> result.put(key, 
Collections.singleton(new DataNode(value.getDataSourceName(), 
value.getTableName()))));
          ......
       }
   ```
   
   TableMetaDataLoader
   ```
   private static boolean isTableExist(final Connection connection, final 
String tableNamePattern) throws SQLException {
           try (ResultSet resultSet = 
connection.getMetaData().getTables(connection.getCatalog(), 
connection.getSchema(), tableNamePattern, null)) {
               return resultSet.next();
           }
       }
   ```
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to