Performing and Caching

  • Database and Application Level Performance Tuning
  • Caching Strategies

Performance Tuning

Database level

  • Data Model:  The data model design can significantly impact the performance of the OR mapping.
  • Normalized vs. Flat Table Design

Query Tuning

  • JOIN: Revisit how you do the join (“join fetch”)
  • Fetch mode: Fetch entities that are lazy fetched using “fetch” keyword rather than walking through (looping) the mapped entities if you know you will need them in advance.
  • Static (Named) Queries: Use Static (Named) Queries where possible
  • Use query hints to control caching

Object Model

  • Lazy loading: Without lazy loading, the performance may take a huge hit. Revisit your objects to avoid loading unnecessary objects in your object graph, lazy fetch objects where possible
  • Unneeded columns: If possible do not include columns that are not needed in the entity definition (make sure schema creation/update is OFF)

Caching Strategies

  • By default hibernate uses EhCache as the default 2nd level cache provider, no configuration is needed
  • Cache provider: To furthur fine tune your application, you need to find the most appropriate cache provider for your application. Revisit the cache configuration to reflect the unique needs of your application.
  • Cache Types
  • Case: Hibernate

References