<p dir="auto">sharding-proxy 4.0.0.RC<br>
postgresql 10.4</p>
<p dir="auto">when i use the sharding-proxy manage two node pg server<br>
the console log show that<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/18464734/65507128-caaef080-deff-11e9-927a-12bc281905f2.png"><img src="https://user-images.githubusercontent.com/18464734/65507128-caaef080-deff-11e9-927a-12bc281905f2.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/18464734/65507208-fc27bc00-deff-11e9-85a4-f28121de78e3.png"><img src="https://user-images.githubusercontent.com/18464734/65507208-fc27bc00-deff-11e9-85a4-f28121de78e3.png" alt="image" style="max-width: 100%;"></a></p>
<h2 dir="auto">Bug Report</h2>
<h3 dir="auto">Which version of Sharding-Sphere did you use?</h3>
<p dir="auto">3.0.0.M3</p>
<h3 dir="auto">Which project did you use? Sharding-JDBC or Sharding-Proxy?</h3>
<p dir="auto">Sharding-JDBC</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">The construction of ShardingDataSource costs less than 10 sec.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">Base on Oracle, it costs 23 seconds to initialize an object of ShardingDataSource when the count of tables in default datasource is 167.</p>
<h3 dir="auto">Reason analyze (If you can)</h3>
<p dir="auto">During the initialization process, the ShardingMetaData will be construcated, in which the TableMetaData of all tables comming from default-datasource would be loaded. As there are 167 tables in my default datasource, the times of database access would be 167*3. Meanwhile  the database access is in turn, which is very time-consuming.</p>
<p dir="auto">The key code is as follows:</p>
<ul dir="auto">
<li>io.shardingsphere.core.metadata.table.executor.TableMetaDataInitializer</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public Map&lt;String, TableMetaData&gt; load(final ShardingRule shardingRule) {
        Map&lt;String, TableMetaData&gt; result = new HashMap&lt;&gt;();
        try {
            result.putAll(loadShardingTables(shardingRule));
            result.putAll(loadDefaultTables(shardingRule)); // the entry 
        } catch (final SQLException ex) {
            throw new ShardingException(ex);
        }
        return result;
    }"><pre class="notranslate"><code class="notranslate">public Map&lt;String, TableMetaData&gt; load(final ShardingRule shardingRule) {
        Map&lt;String, TableMetaData&gt; result = new HashMap&lt;&gt;();
        try {
            result.putAll(loadShardingTables(shardingRule));
            result.putAll(loadDefaultTables(shardingRule)); // the entry 
        } catch (final SQLException ex) {
            throw new ShardingException(ex);
        }
        return result;
    }
</code></pre></div>
<ul dir="auto">
<li>io.shardingsphere.core.metadata.table.executor.TableMetaDataLoader</li>
</ul>
<ol dir="auto">
<li>The method isTableExist() costs one database access</li>
<li>The method getColumnMetaDataList() costs two database access. One is getPrimaryKeys and the other is getColumns.</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="private Collection&lt;TableMetaData&gt; load(final String dataSourceName, final String catalog, final Collection&lt;DataNode&gt; dataNodes) throws SQLException {
        Collection&lt;TableMetaData&gt; result = new LinkedList&lt;&gt;();
        try (Connection connection = connectionManager.getConnection(dataSourceName)) {
            for (DataNode each : dataNodes) {
                result.add(new TableMetaData(
                        isTableExist(connection, catalog, each.getTableName()) ? getColumnMetaDataList(connection, catalog, each.getTableName()) : Collections.&lt;ColumnMetaData&gt;emptyList()));
            }
        }
        return result;
    }"><pre class="notranslate"><code class="notranslate">private Collection&lt;TableMetaData&gt; load(final String dataSourceName, final String catalog, final Collection&lt;DataNode&gt; dataNodes) throws SQLException {
        Collection&lt;TableMetaData&gt; result = new LinkedList&lt;&gt;();
        try (Connection connection = connectionManager.getConnection(dataSourceName)) {
            for (DataNode each : dataNodes) {
                result.add(new TableMetaData(
                        isTableExist(connection, catalog, each.getTableName()) ? getColumnMetaDataList(connection, catalog, each.getTableName()) : Collections.&lt;ColumnMetaData&gt;emptyList()));
            }
        }
        return result;
    }
</code></pre></div>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<p dir="auto">Just find an Oracle database such as db1 and create 100+ tables. It appears when initializing a ShardingDatasource.</p>
<blockquote>
<p dir="auto">sharding.jdbc.config.sharding.default-data-source-name=db1</p>
</blockquote>
<p dir="auto">Could you explain the reason of loading the TableMetaData of default datasource? Is it necessary？<br>
Looking forward for your reply. Thanks a lot!</p>
<h3 dir="auto">Example codes for reproduce this issue (such as a github link).</h3>
<p dir="auto">I will write a sample on github  if you need.</p>