Just some pre-information. We are using a H2 File Database which is already around 15 GB.
Our Application runs on
- Windows Clients
- Jetty Webserver
- H2 File Database
Every time Data needs to be updated on client side, the user will get a zip File with XML-Files. Either an XML file will be imported to the DB or the xml file has a flag "delete" and the entry in the DB will be deleted. Every import of a zip file has a data version. The import is done manually with Java. XML Files are deserialized to POJOs and mapped to our Domain Entitys.
With this, we are also able to make a full import of all data to the Database (which just takes ages - 8h).
To our issue:
The table where our problem occurs has around 290.000 rows.
We have a named query:
@NamedNativeQuery(name="getRawTecdocWithMaxVersionAndGivenLocale",
query = "select tdo.tecdoc_guid as guid, tdo.tecdoc_locale as locale , tdo.tecdoc_version as version, tdo.data as data "
+ " from TECDOC_OBJECTS tdo "
+ " left outer join TECDOC_OBJECTS tdo1 "
+ " on (tdo.tecdoc_guid = tdo1.tecdoc_guid and tdo.tecdoc_locale = tdo1.tecdoc_locale and tdo.tecdoc_version < tdo1.tecdoc_version) "
+ " where tdo1.id is null "
+ " and tdo.tecdoc_guid in ( ?1 ) "
+ " and tdo.tecdoc_locale = ?2 ",
resultSetMapping = "rawTecdocs")
Which gets quite slow around 1 sec after a data update (zip file import). The actual query, with given guid did not change after the data update.
We have index on the columns which are selected.
Where it gets strange
If we fill our Database with a full update (all 15GB of data imported through XML), the query seems to be "fast" (20-50 ms) again.
Maybe someone has a hint for me/us to overcome this issue?