diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java index 661a7893b03aee4..74eb91ddfb5c47c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java @@ -1183,6 +1183,11 @@ public long getRowCount() { return rowCount; } + @Override + public long getCacheRowCount() { + return getRowCount(); + } + @Override public long getAvgRowLength() { long rowCount = 0; diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java index 30b0c9da4b2c2d9..ff7d417089990a5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java @@ -345,6 +345,10 @@ public long getRowCount() { return 0; } + public long getCacheRowCount() { + return getRowCount(); + } + public long getAvgRowLength() { return 0; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java index e5f14a8a31ef2f8..95be8bc07b279bd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java @@ -121,6 +121,8 @@ default int getBaseColumnIdxByName(String colName) { long getRowCount(); + long getCacheRowCount(); + long getDataLength(); long getAvgRowLength(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/external/ExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/external/ExternalTable.java index a915136193c8911..57073299eb19540 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/external/ExternalTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/external/ExternalTable.java @@ -281,6 +281,10 @@ public long getRowCount() { return 0; } + public long getCacheRowCount() { + return 0; + } + @Override public long getAvgRowLength() { return 0; diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/external/HMSExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/external/HMSExternalTable.java index fb1c10002473bb9..c7c4e0b970ce131 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/external/HMSExternalTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/external/HMSExternalTable.java @@ -456,6 +456,23 @@ public List getHudiSchema(List hmsSchema) { return tmpSchema; } + @Override + public long getCacheRowCount() { + //Cached accurate information + TableStatsMeta tableStats = Env.getCurrentEnv().getAnalysisManager().findTableStatsStatus(id); + if (tableStats != null) { + long rowCount = tableStats.rowCount; + LOG.debug("Estimated row count for db {} table {} is {}.", dbName, name, rowCount); + return rowCount; + } + + //estimated information + if (estimatedRowCount != -1) { + return estimatedRowCount; + } + return -1; + } + @Override public long estimatedRowCount() { try { diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/external/JdbcExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/external/JdbcExternalTable.java index a02c59080fc4ebd..e0d03dc53dd52b6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/external/JdbcExternalTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/external/JdbcExternalTable.java @@ -120,6 +120,11 @@ public long getRowCount() { return 1; } + @Override + public long getCacheRowCount() { + return getRowCount(); + } + @Override public long estimatedRowCount() { return getRowCount(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java index 65fc162279b5d9f..1e449eb2026f9cb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java +++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java @@ -746,7 +746,7 @@ public TListTableStatusResult listTableStatus(TGetTablesParams params) throws TE status.setUpdateTime(table.getUpdateTime() / 1000); status.setCheckTime(lastCheckTime / 1000); status.setCollation("utf-8"); - status.setRows(table.getRowCount()); + status.setRows(table.getCacheRowCount()); status.setDataLength(table.getDataLength()); status.setAvgRowLength(table.getAvgRowLength()); tablesResult.add(status);