Skip to content
Permalink
Browse files

0003817: Initial load use estimated counts

  • Loading branch information...
erilong committed Dec 6, 2018
1 parent 10cbda7 commit ff8b63330ac70b529dfcc02ca198f9ad0742eab3
@@ -22,6 +22,8 @@

import javax.sql.DataSource;

import org.apache.commons.lang.StringUtils;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.DatabaseNamesConstants;
import org.jumpmind.db.platform.IDdlBuilder;
import org.jumpmind.db.sql.SqlTemplateSettings;
@@ -47,4 +49,14 @@ protected IDdlBuilder createDdlBuilder() {
public String getName() {
return DatabaseNamesConstants.MSSQL2008;
}

@Override
public long getEstimatedRowCount(Table table) {
String catalog = StringUtils.isNotBlank(table.getCatalog()) ? table.getCatalog() + "." : "";
return getSqlTemplateDirty().queryForLong("select sum(p.rows) from " + catalog + "sys.tables t inner join " +
catalog + "sys.partitions p on t.object_id = p.object_id and p.index_id IN (0, 1) " +
"where t.name = ? and schema_name(t.schema_id) = ?",
table.getName(), table.getSchema());
}

}
@@ -4,6 +4,7 @@

import org.apache.commons.lang.StringUtils;
import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.AbstractJdbcDatabasePlatform;
import org.jumpmind.db.platform.DatabaseNamesConstants;
import org.jumpmind.db.platform.PermissionResult;
@@ -111,6 +112,11 @@ public PermissionResult getExecuteSymPermission() {

return result;
}

}

@Override
public long getEstimatedRowCount(Table table) {
return getSqlTemplateDirty().queryForLong("select num_rows from all_tables where table_name = ? and owner = ?",
table.getName(), table.getSchema());
}

}

0 comments on commit ff8b633

Please sign in to comment.
You can’t perform that action at this time.