Greetings.

Without knowing the Table definition and the indexes, nobody will be
able to help.
However, you may look for:

1) the JOINERS are all repetitive, filtering for a particular value of
"key1". Instead repeating for each value, just use "key1" for the
aggregation.
2) ensure, that "key1" and "val" are indexed and that those indices are
used. Beware losing the index access when introducing the sub-queries.
Depending on your data volume, it may be more efficient, to write the
sub-queries into a temporary table, then index that and run the main
query on the indexed temporary table. 
3) avoid the "val != 'NaN'" as it will likely result in a full table
scan. Instead, write something like " val IN (...)" which can used
indexes (at least with latest Git Snapshot, if I understood latest
commits correctly)

4) run you query against H2 directly and eliminate the Spring/Hibernate
Layer. Get a proper execution plan and check the reads and used
indices.
Avoid Full table Scans at all cost.

Good Luck!
Andreas

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/663582052f72fb884c24968584482125142eadc7.camel%40manticore-projects.com.

Reply via email to