Thursday, March 13, 2008

Compressing a table in Apache Derby

If rows are deleted from the Apache Derby Database, the table doesn't get compressed automagically. You need to execute the following command with derby utility "ij".
call SYSCS_UTIL.SYSCS_COMPRESS_TABLE('SCHEMA-NAME', 'TABLE-NAME', 1)
The third option is something called "sequential" which takes less memory and space, as you have guessed it, more time. But, really it is not that slow. It reduced the 1.3 G table to 600M in less than a minute. More gyaan on the man page.

Labels: , ,


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: ,


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

Subscribe to Posts [Atom]