DB2 uses a cost based query optimizer based on distribution statistics of the actual data. Unfortunately there is no distribution statistics for geometry attributes. As a consequence, the optimizer is not able to deal with spatial indices correctly.
The full description is here:
It is possible to give a hint to the optimizer.
The idea is to add a param
to the class DB2NGDataStoreFactory which defaults to FALSE.
If the param is TRUE, the selectivity clause will be used.