[hibernate-dev] Where are the batched fetch statements generated?
Hi, Sorry for posting to the developers list, I have tried all other places dedicated to end-user support, however it seems the question is too in-depth :/ Is it possible to disable prepared statement caching for batched fetching, so I end up with a single query in the < default_batch_fetch_size case only instead of the fixed-size batch loading hibernate does by default? If its not configureable, I would be really grateful for a pointer to the source where that caching and sub-batch-by-sub-batch loading is done. I am latency bound with a low-loaded postgresql-server, so I would be happy if I could trade lower server load with less roundtrips. Thank you in advance, Clemens ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] Where are the batched fetch statements generated?
Hi, Because of the lack of feedback, I decided to start hacking blindly ;) Generating the Loaders on demand broke for an unknown reason, so what I do now is to pad the batch-load request with non-existant primary keys up to the next larger batch-size and distribute the batch-sizes a bit more uniform. Works great so far - for my use-cases I almost always get only one query - so I get almost the same amount of roundtrips as with SUBSELECT fetching, only with a lot less complex queries. If there is some interest, I would be happy to share the patches. (although its quite hackish, not ready for general consumption) Thanks, Clemens ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] Where are the batched fetch statements generated?
Hi Guenther, >>> Is it possible to disable prepared statement caching for batched fetching, >>> so I end up with a single query in the < default_batch_fetch_size case only >>> >>instead of the >>> fixed-size batch loading hibernate does by default? > I think the main reason for no feedback so far, is that nobody was able to > understand this sentence. > Usually 'prepared statement caching' is a synonym to 'prepared statement > pooling' and is something which has to be provided by a connection-pool (or a > jdbc-driver) and thus > Hibernate does actually not implement any prepared statement cache/pooling. > Can you please explain what you intend under 'prepared statement caching'? > Can you also please try to better explain the second part of your sentence? Sorry for beeing that cryptic, I will try to rephrase it: When Hibernate does batch-fetching, it generates PreparedStatements for certain batch sizes - for a batch_size of 50, the prepared statements for batch-sizes will have the following sizes: [1,2,3,4,5,6,7,8,9,10,12,25,50]. When e.g. a batch of size 13 should be fetched, because of the fixed size of the prepared statements, 3 queries are issued for batch-fetching, although 13 <= 50. In this case the 3 batches would be of the size 13 = 8 + 4 + 1. In a latency bound (between db and application) environment, this serverly hampers response time - instead of a single round-trip to do the batched fetch, Hibernate requires 3. (subselect can't be used in my case, because my queries are already rather complex, and the added complexity confuses the DBs query planner too much) What I did in this case (only for integer PKs) is to pad up to the next batch size with a non-existant PK. So, for the example mentioned above, I can use the PreparedStatement with size 25, and insert padding from 14-25, which will make the query slightly more inefficient but avoid 2 additioan round-trips. - Clemens ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] Where are the batched fetch statements generated?
Hi Steve, Sorry I missed the original series of emails, as unbelieveable as it sounds, gmail was acting strange recently... Ok, this is pushed to master. All 3 styles are implemented. See > issue for details. > > On Thu, Nov 1, 2012 at 2:43 PM, Steve Ebersole > wrote: > > fwiw... I have a lot of this implemented locally. At the moment it is > > "swappable", but I have not yet exposed this as a setting. Also, I only > > have (1) and (2) implemented. (2) is implemented by padding with the > main > > identifier that triggered the batch load. > > > > Plan is to work on (3) tomorrow, if I do not get to it today. > This is really great news, it actually allows me to drop my hacked version of hibernate-3.6 and finally update to 4.x. I guess dynamically generating the statement is what I am really looking for. I'll give it a try soon, thanks again =) - Clemens ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev