I think this could be a case where the query optimizer could use some work? Is it useful for me to file a bug report somewhere, e.g. in JIRA?
Yes, it would be particularly helpful if you could provide a complete standalone test case which demonstrates the problem.
If that's not possible, then perhaps you could gather query plan output and post that; perhaps the Derby optimizer is choosing a particularly poor query plan.
Can anyone suggest how I could work around the OOM error?
You can control Derby's memory usage by simply allocating more memory to your JVM when you run Derby, typically by specifying -Xmx. Try something like -Xmx1024m and see if that avoids the out-of-memory problem. Of course, you don't want to specify a number larger than the actual amount of physical memory on your computer, so if your computer only has, e.g., 512m of physical memory, use something like -Xmx384m You can find some pointers to suggestions about studying Derby performance issues here: http://wiki.apache.org/db-derby/PerformanceDiagnosisTips thanks, bryan
