Optimized Database access

Optimized Database Interaction:

While writing applications for interacting with database using JDBC or using ORM tools like hibernate, we face the problem of optimizing the memory and resource usage. Some tips that would be handy in this:
1. Always close the statements and other resources object after use.
2. Select the specific required fields instead of getting all fields.
   eg.
     Use 
         Select OrderId,ItemId from  orderDetails
     instead of
         select * from orderDetails
3. Use Connection pools
4. Prefer stored procedures instead of direct SQL
5. Turn autocommit off if  not using stored procedures but dont let transactions wait for too long.
6. Tune the SQL to return the minimised data return.
7. User joins instead of sub-queries if possible.
8. Cache data to avoid multiple DB calls for the same data.

Comments

Popular posts from this blog

How to solve “svn: Checksum mismatch while updating..” ?

Install Jenkins and configure with mercurial repo for Continous Integration