Trying to optimize the time it takes for us to build objects using Hibernate ORM. Moved from using a batch size of 10 on our collections to using fetch mode subselect. Worked great and it about halved our time to display results to the search.
However mass indexing is running at about half speed, and for certain batches can take several minutes, where as before it was usually sub second. One of our indexes fails completely at about 10% due to an SSL exception (SSL peer shutdown incorrectly) which looks like some kind of query timeout (either on our or the DB providers end).
After doing some research it looks like this may be related to an existing bug on hibernate ORM ([HHH-11466] limit not used for subselect - Hibernate JIRA). It appears that hibernate ignores LIMIT and other parts of the first query, thus loading more into memory than it needs. Could this explain the slower performance and eventual timeout?
Whether or not it is related to issues within Hibernate ORM, is there anything we can do to avoid these issues when massindexing, as I would really like to keep the performance benefit on our load times?