Some suggestions for optimizing hibernate performance using java and some suggestions for hibernate
1 <property name = "hibernateProperties">
2 <props>
3 <prop key = "hibernate. dialect"> org. hibernate. dialect. Oracle9Dialect </prop>
4 <prop key = "hibernate. show_ SQL"> false </prop>
5 <! -- Create/update the database tables automatically when the JVM starts up
6 <prop key = "hibernate. hbm2ddl. auto"> update </prop> -->
7 <! -- Turn batching off for better error messages under PostgreSQL
8. <prop key = "hibernate. jdbc. batch_size"> 100 </prop> -->
9 <prop key = "hibernate. jdbc. batch_size"> 50 </prop>
10 </props>
11 </property>
The larger the Fetch Size is, the smaller the number of reads to the database, and the faster the speed. The smaller the Fetch Size, the more reads the database and the slower the speed.
2. If it is an ultra-large system, it is recommended to generate an htm file. Speed up page improvement.
3. Do not place all responsibilities on hibernate, refactor the code, reduce database operations, avoid using in operations in database queries, and avoid recursive query operations, the rationality of code quality and system design determines the system performance.
4. When querying large data volumes, use list () or iterator () to return the query results with caution,
(1) When List () is used to return results, Hibernate initializes all query results as persistent objects. When the result set is large, it takes a lot of processing time.
(2 ). when iterator () is used to return results. when next () returns an object and uses the object, Hibernate calls the query to initialize the corresponding object. For a large amount of data, it takes a lot of time to call each query. Iterator () is advantageous when the result set is large but contains a large amount of the same data, or not all of the result sets are used.
5. Using the delayed loading mechanism in the one-to-many and many-to-one relationship will enable initialization of many objects during use, which can save memory space and reduce database load, in addition, if the set in the PO is not used, the interaction between databases can be reduced to reduce the processing time.
6. If default-cascade = "all" or "save-update" is used for a PO (persistence object) with an association, pay attention to the value assignment operation for the set in the PO, because it is possible to execute an update operation more than once.
7. The number of interactions with databases is the most important factor determining the processing time for new, modify, or delete operations on large data volumes or queries on large data volumes, reducing interactions is the best way to improve efficiency. Therefore, during the development process, set show_ SQL to true to gain an in-depth understanding of the Hibernate processing process and try different methods, this improves efficiency. Minimize the number of database operations on each page. The fewer the better.
The above are some experiences on hibernate performance optimization during struts + hibernate + spring project development.