Skip to content
Permalink
Browse files

perf: ignore tables for PgDatabaseMetaData.getTypeInfo (#1302)

PostgreSQL considers tables to be composite types which
in very large schemas with lots of tables slows down getTypeInfo.
This fix filters out tables from types
  • Loading branch information...
davecramer committed Oct 16, 2018
1 parent 10201f6 commit e44e4e8972ec41bf05dddd4ac6dcfbc42a9842cf
Showing with 3 additions and 1 deletion.
  1. +3 −1 pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java
@@ -2224,7 +2224,9 @@ public ResultSet getTypeInfo() throws SQLException {
String sql;
sql = "SELECT t.typname,t.oid FROM pg_catalog.pg_type t"
+ " JOIN pg_catalog.pg_namespace n ON (t.typnamespace = n.oid) "
+ " WHERE n.nspname != 'pg_toast'";
+ " WHERE n.nspname != 'pg_toast'"
+ " AND "
+ " (t.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid))";

Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sql);

0 comments on commit e44e4e8

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