{"record":{"id":"6b20daec872f1134","repo":"apache/seatunnel","slug":"failed-to-get-approximate-row-count-from-table-sta","errorCode":null,"errorMessage":"Failed to get approximate row count from table status, fallback to count rows","messagePattern":"Failed to get approximate row count from table status, fallback to count rows","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/redshift/RedshiftDialect.java","lineNumber":170,"sourceCode":"                                        .equals(table.getTablePath().getFullName()));\n        if (useTableStats) {\n            String rowCountQuery =\n                    String.format(\n                            \"SELECT reltuples FROM pg_class r WHERE relkind = 'r' AND relname = '%s';\",\n                            table.getTablePath().getTableName());\n            try (Statement stmt = connection.createStatement()) {\n                log.info(\"Split Chunk, approximateRowCntStatement: {}\", rowCountQuery);\n                try (ResultSet rs = stmt.executeQuery(rowCountQuery)) {\n                    if (!rs.next()) {\n                        throw new SQLException(\n                                String.format(\n                                        \"No result returned after running query [%s]\",\n                                        rowCountQuery));\n                    }\n                    return rs.getLong(1);\n                }\n            } catch (SQLException e) {\n                log.warn(\n                        \"Failed to get approximate row count from table status, fallback to count rows\",\n                        e);\n                return SQLUtils.countForTable(connection, tableIdentifier(table.getTablePath()));\n            }\n        }\n        return SQLUtils.countForSubquery(connection, table.getQuery());\n    }\n}\n","sourceCodeStart":152,"sourceCodeEnd":179,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/redshift/RedshiftDialect.java#L152-L179","documentation":"RedshiftDialect.approximateRowCntStatement first tries a fast approximate row count from Redshift's system table (STV_TBL_PERM). On SQLException, or when the query returns no rows, it logs this warning and falls back to an exact COUNT(*) on the table.","triggerScenarios":"SELECT from STV_TBL_PERM fails (permission denied, table absent from system view, transient connection error) during split enumeration for JDBC source on Redshift.","commonSituations":"User lacking access to Redshift system tables; recently created/renamed tables not yet in STV_TBL_PERM; transient cluster connectivity issues.","solutions":["No action needed - it falls back to COUNT(*) automatically","Grant the sync user SELECT on system tables (or elevated perms) to keep the fast path","Verify the table exists/is visible to the user in Redshift"],"exampleFix":"null","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// behavior is already a fallback; just log-monitor\nif (log.contains(\"fallback to count rows\")) { /* consider granting STV_TBL_PERM access */ }","preventionTips":["Grant the SeaTunnel user access to Redshift system tables for fast row counts","Ignore this warning unless slow splits on huge tables become a problem"],"tags":["jdbc","redshift","row-count","fallback"],"backgroundTag":"sql-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}