This commit is contained in:
Gianpaolo Coro 2015-02-03 14:03:24 +00:00
parent d52833272e
commit af8419ac0f
1 changed files with 9 additions and 1 deletions

View File

@ -35,7 +35,15 @@ public class DatabaseUtils {
private String primaryK;
private String primaryKColName;
public static long estimateNumberofRows(String table, SessionFactory dbconnection) throws Exception{
List<Object> explain = DatabaseFactory.executeSQLQuery("EXPLAIN SELECT * FROM "+table, dbconnection);
String explained = "" + explain.get(0);
explained = explained.substring(explained.lastIndexOf("rows="));
explained = explained.substring(explained.indexOf('=') + 1, explained.indexOf(' '));
return Long.parseLong(explained);
}
private void getPrimaryKeys(List<Object> keys, String table) {
int keynum = 0;
if (keys != null)