Friday, March 07, 2008

DB query tip

Hit a performance problem with Apache derby, which turned out not to be Derby specific problem anyway. The tip that the day is avoiding queries which incur entire table scan:


SELECT DISTINCT nonIndexedCol FROM HugeTable;

SELECT * FROM HugeTable ORDER BY nonIndexedColumn;


For Derby, the table is called "huge" if it has more than few thousand rows. (It's an embedded database.)

To debug derby performance, set the properties given below and watch derby.log

System.setProperty("derby.language.logQueryPlan", "true");
System.setProperty("derby.language.logStatementText", "true");

Also, realized that

Labels: ,


Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]