Issue Details (XML | Word | Printable)

Key: DERBY-1996
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Andy Jefferson
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Derby

DatabaseMetaData.getColumns() takes long time to return columns for a particular schema of Apache JDO TCK

Created: 24/Oct/06 06:30 PM   Updated: 08/Jul/09 02:10 PM
Return to search
Component/s: SQL
Affects Version/s: 10.2.1.6
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Zip Archive testcase.zip 2006-10-24 06:31 PM Andy Jefferson 59 kB
Issue Links:
Reference
 

Urgency: Normal
Issue & fix info: Repro attached
Bug behavior facts: Performance


 Description  « Hide
When running the Apache JDO "TCK", JPOX needs to query the columns for a particular schema, and so uses DatabaseMetaData.getColumns(null, schemaName, null, null). This takes the order of 3 minutes on a dual-core Pentium 3GHz (with large ram). I've cut the JPOX part down to a stand-alone test (will attach it).

Thing to note is that with only the schema files d_* installed it takes the order of 20secs. When the schema_* files are also installed then performance goes downhill fast (even though they are in different schemas ... all *.sql file represents a different schema). No point in me postulating what could be the issue since you guys are the Derby experts.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 24/Oct/06 06:31 PM
To run the test, i've included Maven1 files.

maven clean installschema
will install all *.sql files

maven jar runtest
will run a simple JDBC test of DatabaseMetaData.getColumns()

Andy Jefferson added a comment - 05/Aug/08 02:20 PM
Any comment on when (approx) DatabaseMetaData.getColumns will be capable of giving reasonable performance in situations like this? or is there some SELECT that we can do ourselves to get the same basic information without having to go through getColumns() ?? Thx

Rick Hillegas added a comment - 05/Aug/08 03:05 PM
Hi Andy,

It doesn't look like anyone is working on this issue. You can vote for it and you can advocate for it on derby-dev or derby-user. Note that there are 3 weeks left before we cut the 10.4.2 release.

The following query may give you some of what you need. I have no idea how this query performs on your schema:

select s.schemaname, t.tablename, c.columnname, c.columnnumber, c.columndatatype
from sys.sysschemas s, sys.systables t, sys.syscolumns c
where c.referenceid = t.tableid
and t.schemaid = s.schemaid
and t.tabletype = 'T'
order by s.schemaname, t.tablename, c.columnname, c.columnnumber
;

A couple points about this query:

o You can adjust this query by consulting the layout of the system tables. That layout is described in the Derby Reference Guide.

o The columndatatype column is an object of type org.apache.derby.catalog.TypeDescriptor. That class is not in Derby's public API and therefore is not guaranteed to be stable across releases (although my sense is that it has tended to evolve in upward-compatible ways).

Knut Anders Hatlen added a comment - 08/Jul/09 02:10 PM
Triaged for 10.5.2.