提交 146b429a 编写于 作者: S Serge Rider

#9284 PG partitioned tables total size calc

上级 a3992750
......@@ -158,6 +158,30 @@ public abstract class PostgreTable extends PostgreTableReal implements PostgreTa
this.partitionKey = partitionKey;
}
@Override
protected void fetchStatistics(JDBCResultSet dbResult) throws DBException, SQLException {
super.fetchStatistics(dbResult);
if (diskSpace != null && diskSpace == 0 && hasSubClasses) {
// Prefetch partitions (shouldn't be too expensive, we already have all tables in cache)
getPartitions(dbResult.getSession().getProgressMonitor());
}
}
@Override
public long getStatObjectSize() {
if (diskSpace != null && diskSpace == 0 && subTables != null) {
long partSizeSum = 0;
for (PostgreTableInheritance ti : subTables) {
PostgreTableBase partTable = ti.getParentObject();
if (partTable instanceof PostgreTableReal) {
partSizeSum += ((PostgreTableReal) partTable).getStatObjectSize();
}
}
return partSizeSum;
}
return super.getStatObjectSize();
}
@Override
public Collection<PostgreIndex> getIndexes(DBRProgressMonitor monitor) throws DBException {
return getSchema().indexCache.getObjects(monitor, getSchema(), this);
......
......@@ -163,7 +163,7 @@ public abstract class PostgreTableReal extends PostgreTableBase implements DBPOb
}
}
protected void readTableStatistics(JDBCSession session) throws SQLException {
protected void readTableStatistics(JDBCSession session) throws DBException, SQLException {
try (JDBCPreparedStatement dbStat = session.prepareStatement(
"select " +
"pg_catalog.pg_total_relation_size(?) as total_rel_size," +
......@@ -179,7 +179,7 @@ public abstract class PostgreTableReal extends PostgreTableBase implements DBPOb
}
}
protected void fetchStatistics(JDBCResultSet dbResult) throws SQLException {
protected void fetchStatistics(JDBCResultSet dbResult) throws DBException, SQLException {
diskSpace = dbResult.getLong("total_rel_size");
tableRelSize = dbResult.getLong("rel_size");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册