Hibernate + MySQL. Ways to optimize selecting and loading data -


i'd test how selecting , loading data in java application using hibernate , mysql can optimized.

i divided results found 2 groups

mysql

  • indexes - sure
  • stored procedures - there difference if select done in stored procedure?
  • views - there difference if select definition kept in view?
  • query cache - work if same select second time?

hibernate

  • hibernate cache - similar query cache? how can configured?
  • lazy loading - can help?

are there other ways? use simple queries several joins , aggregation functions. need demonstate time changes between "before" , "after" optimization.

for more information tried read this, language complicated me.

  1. batch fetching important when read e.g. collection. in case hibernate can many rows of collection in 1 sql request, faster.
  2. hibernate caching solution (read ehcache instance) can store retrieved data on memory , if nothing changes on side can retrieve without asking sql engine what's going on there.
  3. lazy loading must 1 many associations (you can kill solution without this). fortunately set default in hibernate such associations.

you can read optimistic lock, faster pessimistic lock in many cases.

last not least should use proper transaction strategy, shouldn't create new transactions when not necessary.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -