Hi Friends
I m facing huge performance issues while inserting and updating the tables using hibernate.
Please take a look at below scenario
1) At normal flow when there are nearly 50-70 requests every thing works well it takes the insert and update on table max 200-250 milliseconds. 2) When number of requests inicreases to 100-150 every thing goes down.
TablesTable 1) TransTable 2) TransDetail For
Table 1) Nothing fails means what ever be the number of requests it works fine but for inserting values in Table 2) it takes nearly
20000 Milliseconds to insert the record.
Number of rows in both the table are same and possibly it is greater than
15000000 rows
Partitions are provided on Table 1) UPDATED_DATE Column .
Table 2) No Partitions are given .
Can any one help me out with proper resolution .
Extract of code which updates both the tables
Code:
hibernateSession.saveOrUpdate(trans);
hibernateSession.flush(); // Takes 30 Millisecs to insert or update
hibernateSession.saveOrUpdate(transDetail);
hibernateSession.flush();// Takes 20000 Millisecs to insert
trans.setTransDetail(transDetail);
hibernateSession.flush();// Takes 10 Millisecs to insert or update
Below are hbm.xml extract for the tables for which the issue is coming
Table 1) <class
name="com.hibernate.Trans"
table="TRANS"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="TRANS"
</meta>
<id
name="transactionsId"
type="java.lang.Long"
column="TRANS_ID"
>
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
type="java.lang.Long"
column="TRANS_ID"
</meta>
<generator class="sequence">
<param name="sequence">TRANS_ID_SEQ</param>
</generator>
</id>
<property
name="updatedDate"
type="java.util.Date"
column="UPDATED_DATE"
>
<meta attribute="field-description">
@hibernate.property
column="UPDATED_DATE"
</meta>
</property>
.
.
.
.
.
<!-- associations -->
<!-- bi-directional many-to-one association to TransDetail -->
<many-to-one
name="transDetail"
class="com.hibernate.TransDetail"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="DETAIL_TRANS_ID"
</meta>
<column name="DETAIL_TRANS_ID" />
</many-to-one>
</class>
</hibernate-mapping> Table 2) <class
name="com.hibernate.TransDetail"
table="TRANS_DETAILS"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="TRANS_DETAILS"
</meta>
<id
name="detailTransId"
type="java.lang.Long"
column="DETAIL_TRANS_ID"
>
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
type="java.lang.Long"
column="DETAIL_TRANS_ID"
</meta>
<generator class="sequence">
<param name="sequence">DETAIL_TRANS_ID_SEQ</param>
</generator>
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
<!-- bi-directional one-to-many association to Transaction -->
<set
name="trans"
lazy="true"
inverse="true"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
@hibernate.collection-key
column="DETAIL_TRANS_ID"
@hibernate.collection-one-to-many
class="com.hibernate.Trans"
</meta>
<key>
<column name="DETAIL_TRANS_ID" />
</key>
<one-to-many
class="com.hibernate.Trans"
/>
</set>
>
</class>
</hibernate-mapping>