Web hosting billing - Selecting a fetch strategy @org.hibernate.annotations.BatchSize(size = 10) private

Selecting a fetch strategy @org.hibernate.annotations.BatchSize(size = 10) private Set bids = new HashSet(); … } Prefetching proxies and collections with a batch strategy is really a blind guess. It s a smart optimization that can significantly reduce the number of SQL statements that are otherwise necessary to initialize all the objects you re working with. The only downside of prefetching is, of course, that you may prefetch data you won t need in the end. The trade-off is possibly higher memory consumption, with fewer SQL statements. The latter is often much more important: Memory is cheap, but scaling database servers isn t. Another prefetching algorithm that isn t a blind guess uses subselects to initialize many collections with a single statement. 13.2.2 Prefetching collections with subselects Let s take the last example and apply a (probably) better prefetch optimization: List allItems = session.createQuery(”from Item”).list(); processBids( (Item)allItems.get(0) ); processBids( (Item)allItems.get(1) ); processBids( (Item)allItems.get(2) ); You get one initial SQL SELECT to retrieve all Item objects, and one additional SELECT for each bids collection, when it s accessed. One possibility to improve this would be batch fetching; however, you d need to figure out an optimum batch size by trial. A much better optimization is subselect fetching for this collection mapping: Hibernate now initializes all bids collections for all loaded Item objects, as soon as you force the initialization of one bids collection. It does that by rerunning the first initial query (slightly modified) in a subselect:
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Leave a Reply