Posts Tagged ‘Performance’

Learnings from the Past: Hibernate related Best Practices

Thursday, March 18th, 2010

Back to blogging after a gap of 8 months. I have been working on some cool optimization stuff related to Hibernate. Here is a brief summary of the best practices i have come across on this and past assignments involving Hibernate.

# Practice What? Why? How?
1 Use Lazy Load Don’t load objects until you need to use them. Queries involve lesser joins, so become faster By Using @Lazy annotation for simple attributes and LazyCollection for Collections
2 Use allocationSize>1 for Sequences Use an allocationSize value of 50 or 100 instead of the default allocationSize of 1 Avoids frequent db access to fetch next sequence value By using @allocationSize=50, Hibernate will generate the next sequence values for 50 invocations before hitting the db again.
3 Keep big character/byte fields in a seperate entity Seperate big fields like blob, clob, varchar(500), etc., into a seperate entity called <enityName>Details Avoids time spent in fetching data for these fields on listing screens which do not typically display this information By using a one-to-one mapping with the details object and keeping the direction of association from main->detail
4 Use Hibernate Caching Using Hibernate Second Level cache and Query cache to store frequently used objects/results Avoids hitting the db for frequently used information Turn on Hibernate Second level cache and Quey cache

YSlow from Yahoo!

Friday, August 8th, 2008

What is YSlow?
YSlow a plugin for Firefox which analyzes web pages and suggests changes to improve their performance. It’s developed by Yahoo! and is based upon their rules for high performing websites. It gives you a performance scorecard, list of components on the webpage including size, cacheability and load time, and a high level HTTP/HTML Summary. Its one of the coolest tools available out there for web development.

Why use YSlow?
>To make your webpages load faster on the client browser
>Reduce server load by utilizing the browser cache instead of making a server hit.
>Reducing network traffic by gzipping content
>Many more…

What are the pre-requisites for using YSlow?
>Your website needs to be compatible with Firefox so that you can analyze all webpages.
>You need a Firefox web development plugin called Firebug

Where do i get more information on YSlow?
Go to http://developer.yahoo.com/yslow/

Where do i download the YSlow plugin from?
Go to https://addons.mozilla.org/en-US/firefox/addon/5369