You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/09/08 10:41:09 UTC

[GitHub] [shardingsphere] tristaZero commented on a change in pull request #7328: Optimize startup time, ignore load unConfigured table's column and index

tristaZero commented on a change in pull request #7328:
URL: https://github.com/apache/shardingsphere/pull/7328#discussion_r484818640



##########
File path: shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/dql/BaseDQLIT.java
##########
@@ -123,6 +123,9 @@ private void assertMetaData(final ResultSetMetaData actualMetaData, final List<D
         if ("shadow".equals(getRuleType())) {
             return;
         }
+        if (0 == actualMetaData.getColumnCount()) {

Review comment:
       // TODO comment is required.

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/metadata/table/TableMetaDataLoader.java
##########
@@ -54,6 +55,24 @@
         }
     }
     
+    /**
+     * Load table without column and index meta data, this is for unconfigured table.
+     *
+     * @param dataSource data source
+     * @param table table name
+     * @param databaseType database type
+     * @return table meta data
+     * @throws SQLException SQL exception
+     */
+    public static Optional<TableMetaData> loadWithoutColumnMetaData(final DataSource dataSource, final String table, final String databaseType) throws SQLException {
+        try (MetaDataConnection connection = new MetaDataConnection(dataSource.getConnection())) {
+            if (!isTableExist(connection, table, databaseType)) {
+                return Optional.empty();
+            }
+            return Optional.of(new TableMetaData(Collections.emptyList(), Collections.emptyList()));

Review comment:
       // TODO comment is required.

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/metadata/schema/SchemaMetaDataLoader.java
##########
@@ -87,22 +78,11 @@ public static SchemaMetaData load(final DataSource dataSource, final int maxConn
         if (tableNames.isEmpty()) {
             return new SchemaMetaData(Collections.emptyMap());
         }
-        List<List<String>> tableGroups = Lists.partition(tableNames, Math.max(tableNames.size() / maxConnectionCount, 1));
-        Map<String, TableMetaData> tableMetaDataMap = 1 == tableGroups.size()
-                ? load(dataSource.getConnection(), tableGroups.get(0), databaseType) : asyncLoad(dataSource, maxConnectionCount, tableNames, tableGroups, databaseType);
+        Map<String, TableMetaData> tableMetaDataMap = new HashMap<>(tableNames.size(), 1);
+        tableNames.forEach(tableName -> tableMetaDataMap.put(tableName, new TableMetaData(Collections.emptyList(), Collections.emptyList())));

Review comment:
       // TODO comment is required.

##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/refresh/impl/CreateTableStatementMetaDataRefreshStrategy.java
##########
@@ -53,7 +53,7 @@ public void refreshMetaData(final ShardingSphereMetaData metaData, final Databas
     private void refreshUnconfiguredMetaData(final ShardingSphereMetaData metaData, 
                                              final DatabaseType databaseType, final Map<String, DataSource> dataSourceMap, final String tableName) throws SQLException {
         for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
-            Optional<TableMetaData> tableMetaData = TableMetaDataLoader.load(entry.getValue(), tableName, databaseType.getName());
+            Optional<TableMetaData> tableMetaData = TableMetaDataLoader.loadWithoutColumnMetaData(entry.getValue(), tableName, databaseType.getName());

Review comment:
       // TODO comment is required.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org