I am using the Spring JdbcUtils.extractDatabaseMetaData()
method to analyze the database. The function calls a callback and hands over a DatabaseMetaData
object. This object provides the getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
.
I call it like this getColumns("",TABLE_OWNER_USERNAME,null,null)
and get 400 columns as a result. These are exactly the results that I want, but the request takes over 1 minute.
Can I somehow optimize this query to be fast? Pulling 400 rows should happen in 1 seconds and not one minute.
EDIT: I don't suspect the Spring part being slow. Closer analysis showed that fetching the DatabaseMetaData
takes a few seconds butexecuting the getColumns()
takes really long.
Maybe it's a better approach to query ALL_TAB_COLUMNS. Here is an example:
If you need to filter by table simply add " AND TABLE_NAME = ?" to sql and tableName as another parameter.
Hope it helps.