Commit 3cb27155 authored by Stefan Huehner's avatar Stefan Huehner
Browse files

ISSUE-47047 Speedup PG Reading tables - part3

Change calling contract for ModelLoaderBase.readTable(tablename)

Now it must be called with tablename in the correct case.
Only caller left (after cleanup from 47036) in readTables()
Modify the (pg specific) query within to return the proper case
That allows to remove the extra query done in PG.readTable to find the
proper case (_stmt_oids_tables). Note that the 2nd field queried in
there before (table oid) was made obsolete by the previous commit also.

Runtime of Reading tables ... for part1..3 (on example i3-4130)
Before: 8.7 .. 9.7 seconds
After:  5.8 seconds
parent 1aca895f
......@@ -207,12 +207,12 @@ public abstract class ModelLoaderBase implements ModelLoader {
});
}
// On PG this function must be called with tablename is correct case
protected Table readTable(String tablename) throws SQLException {
// on postgres this readTable gets called from the PostgreSqlModelLoader
// with the tablename having the same case as the table has in the database.
// To get same behavior in rest of dbsm which expects the name in uppercase
// we use the uppercase name in the Table object
// on postgres _stmt_listtables query return tablename in the correct case
// as readTables() is the only caller of readTable() that ensure it's being
// called with the correct case
// is in correct case (like in db) on postgres, and in upperCase on oracle
String tableRealName = tablename;
......
......@@ -62,7 +62,6 @@ public class PostgreSqlModelLoader extends ModelLoaderBase {
protected PreparedStatement _stmt_paramtypes;
protected PreparedStatement _stmt_oids_funcs;
protected PreparedStatement _stmt_comments_funcs;
protected PreparedStatement _stmt_oids_tables;
protected Translation _checkTranslation = new PostgreSqlCheckTranslation();
protected Translation _SQLTranslation = new PostgreSQLStandarization();
......@@ -156,7 +155,7 @@ public class PostgreSqlModelLoader extends ModelLoaderBase {
String sql;
boolean firstExpressionInWhereClause = false;
_stmt_listtables = _connection.prepareStatement(
"SELECT UPPER(TABLENAME) FROM PG_TABLES WHERE SCHEMANAME = CURRENT_SCHEMA() "
"SELECT TABLENAME FROM PG_TABLES WHERE SCHEMANAME = CURRENT_SCHEMA() "
+ _filter.getExcludeFilterWhereClause("TABLENAME", _filter.getExcludedTables(),
firstExpressionInWhereClause)
+ " ORDER BY UPPER(TABLENAME)");
......@@ -371,9 +370,6 @@ public class PostgreSqlModelLoader extends ModelLoaderBase {
_stmt_comments_funcs = _connection.prepareStatement("SELECT obj_description(?,'pg_proc')");
_stmt_oids_tables = _connection
.prepareStatement("SELECT oid, relname FROM pg_class WHERE upper(relname) = ?");
}
@Override
......@@ -608,26 +604,6 @@ public class PostgreSqlModelLoader extends ModelLoaderBase {
return f;
}
int oidTable;
// tablename from readTable with the exact case like in the database
String tableRealName;
@Override
protected Table readTable(String tablename) throws SQLException {
_stmt_oids_tables.setString(1, tablename);
fillList(_stmt_oids_tables, new RowFiller() {
@Override
public void fillRow(ResultSet r) throws SQLException {
oidTable = r.getInt(1);
tableRealName = r.getString(2);
}
});
Table t = super.readTable(tableRealName);
return t;
}
// We'll change the types of NVarchar columns (which should have a
// comment in the database)
@Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment