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 2023/01/16 01:46:06 UTC

[GitHub] [shardingsphere] tuichenchuxin commented on a diff in pull request #23564: Optimize `ShardingStatisticsTableCollector` for database postgres

tuichenchuxin commented on code in PR #23564:
URL: https://github.com/apache/shardingsphere/pull/23564#discussion_r1070745385


##########
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/data/ShardingStatisticsTableCollector.java:
##########
@@ -117,6 +123,28 @@ private void addForMySQL(final Map<String, DataSource> dataSources, final DataNo
         row.add(dataLength);
     }
     
+    private void addForPostgreSQL(final Map<String, DataSource> dataSources, final DataNode dataNode, final List<Object> row) throws SQLException {
+        DataSource dataSource = dataSources.get(dataNode.getDataSourceName());
+        BigDecimal tableRows = BigDecimal.ZERO;
+        BigDecimal dataLength = BigDecimal.ZERO;
+        try (
+                Connection connection = dataSource.getConnection();
+                Statement statement = connection.createStatement()) {
+            try (ResultSet resultSet = statement.executeQuery(String.format(POSTGRESQL_TABLE_ROWS_LENGTH, dataNode.getSchemaName(), dataNode.getTableName()))) {
+                if (resultSet.next()) {
+                    dataLength = resultSet.getBigDecimal("TABLE_ROWS");

Review Comment:
   ```suggestion
                       tableRows = resultSet.getBigDecimal("TABLE_ROWS");
   ```



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

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