[information_schema](tables)modify information_schema.tables rows column use cache rows. (#27028)
Use the cached information and estimated information of the table in the rows column under information_schema.tables. Avoid querying information_schema.tables that will cause rpc timeout when there are a large number of tables in the catalog.
This commit is contained in:
@ -1208,6 +1208,11 @@ public class OlapTable extends Table {
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCacheRowCount() {
|
||||
return getRowCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAvgRowLength() {
|
||||
long rowCount = 0;
|
||||
|
||||
@ -344,6 +344,10 @@ public abstract class Table extends MetaObject implements Writable, TableIf {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long getCacheRowCount() {
|
||||
return getRowCount();
|
||||
}
|
||||
|
||||
public long getAvgRowLength() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -121,6 +121,10 @@ public interface TableIf {
|
||||
|
||||
long getRowCount();
|
||||
|
||||
// Get the exact number of rows in the internal table;
|
||||
// Get the number of cached rows or estimated rows in the external table, if not, return -1.
|
||||
long getCacheRowCount();
|
||||
|
||||
long getDataLength();
|
||||
|
||||
long getAvgRowLength();
|
||||
|
||||
@ -282,6 +282,10 @@ public class ExternalTable implements TableIf, Writable, GsonPostProcessable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long getCacheRowCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAvgRowLength() {
|
||||
return 0;
|
||||
|
||||
@ -452,6 +452,23 @@ public class HMSExternalTable extends ExternalTable {
|
||||
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 {
|
||||
|
||||
@ -122,6 +122,11 @@ public class JdbcExternalTable extends ExternalTable {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCacheRowCount() {
|
||||
return getRowCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long estimatedRowCount() {
|
||||
return getRowCount();
|
||||
|
||||
@ -747,7 +747,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user