I only changed hibernate.default_batch_fetch_size value in the config file and the time taken by my application increased from 2 mins to ~8 mins.
When using default_batch_fetch size = 8, query used
Code:
select simsamplec0_.AUTOPOLICYID as AUTOPOLI1_34_11_, simsamplec0_.sampleWeight as sampleWe2_34_11_, autopolicy1_.ID as ID35_0_, autopolicy1_.EffectiveDt as Effectiv2_35_0_, autopolicy1_.ExpirationDt as Expirati3_35_0_, autopolicy1_.PolicyNumber as PolicyNu4_35_0_, address2_.AUTOPOLICYID as AUTOPOLI1_42_1_, address2_.AddrType as AddrType42_1_, address2_.City as City42_1_, address2_.Country as Country42_1_, address2_.County as County42_1_, address2_.State as State42_1_, address2_.Street as Street42_1_, address2_.Zip as Zip42_1_, coverage3_.AUTOPOLICYID as AUTOPOLI1_43_2_, coverage3_.CoverageCd as CoverageCd43_2_, coverage3_.Deductible as Deductible43_2_, coverage3_.Limit as Limit43_2_, customer4_.AUTOPOLICYID as AUTOPOLI1_36_3_, customer4_.CreditScore as CreditSc2_36_3_, customer4_.FirstName as FirstName36_3_, customer4_.LastName as LastName36_3_, customer4_.TaxId as TaxId36_3_, customer4_.TaxIdTypeCd as TaxIdTyp6_36_3_, communicat5_.AUTOPOLICYID as AUTOPOLI1_37_4_, communicat5_.Email as Email37_4_, communicat5_.Phone as Phone37_4_, drivingrec6_.AUTOPOLICYID as AUTOPOLI1_39_5_, drivingrec6_.AnyAccidentInLast3Years as AnyAccid2_39_5_, drivingrec6_.AnyMovingViolationsInLast3Years as AnyMovin3_39_5_, drivingrec6_.LicensedSince as Licensed4_39_5_, drivingrec6_.LicNumber as LicNumber39_5_, drivingrec6_.LicState as LicState39_5_, drivingrec6_.NumYearsLicensed as NumYears7_39_5_, accidentin7_.AUTOPOLICYID as AUTOPOLI2_13_, accidentin7_.INDEX1 as INDEX1_13_, accidentin7_.INDEX1 as INDEX1_40_6_, accidentin7_.AUTOPOLICYID as AUTOPOLI2_40_6_, accidentin7_.AccidentDescription as Accident3_40_6_, accidentin7_.AccidentTypeCd as Accident4_40_6_, accidentin7_.AtFaultInd as AtFaultInd40_6_, accidentin7_.BodilyInjuriesInd as BodilyIn6_40_6_, accidentin7_.DateofAccident as DateofAc7_40_6_, movingviol8_.AUTOPOLICYID as AUTOPOLI2_14_, movingviol8_.INDEX1 as INDEX1_14_, movingviol8_.INDEX1 as INDEX1_41_7_, movingviol8_.AUTOPOLICYID as AUTOPOLI2_41_7_, movingviol8_.DateofViolation as DateofVi3_41_7_, movingviol8_.Incarceration as Incarcer4_41_7_, movingviol8_.MovingViolationsTypeCd as MovingVi5_41_7_, movingviol8_.ViolationDescription as Violatio6_41_7_, persinfo9_.AUTOPOLICYID as AUTOPOLI1_38_8_, persinfo9_.Age as Age38_8_, persinfo9_.DOB as DOB38_8_, persinfo9_.Employer as Employer38_8_, persinfo9_.Gender as Gender38_8_, persinfo9_.HomeOwner as HomeOwner38_8_, persinfo9_.LengthTimeEmployed as LengthTi7_38_8_, persinfo9_.LengthTimewithPrevEmployer as LengthTi8_38_8_, persinfo9_.MaritalStatusCd as MaritalS9_38_8_, persinfo9_.NumDependents as NumDepe10_38_8_, persinfo9_.NumJobChanges as NumJobC11_38_8_, persinfo9_.Occupation as Occupation38_8_, persinfo9_.YrsAtCurrentResidence as YrsAtCu13_38_8_, generalque10_.AUTOPOLICYID as AUTOPOLI2_15_, generalque10_.INDEX1 as INDEX1_15_, generalque10_.INDEX1 as INDEX1_45_9_, generalque10_.AUTOPOLICYID as AUTOPOLI2_45_9_, vehicleinf11_.AUTOPOLICYID as AUTOPOLI2_16_, vehicleinf11_.INDEX1 as INDEX1_16_, vehicleinf11_.INDEX1 as INDEX1_44_10_, vehicleinf11_.AUTOPOLICYID as AUTOPOLI2_44_10_, vehicleinf11_.AnnualMileage as AnnualMi3_44_10_, vehicleinf11_.Color as Color44_10_, vehicleinf11_.LicensePlateNum as LicenseP5_44_10_, vehicleinf11_.LienHolder as LienHolder44_10_, vehicleinf11_.Make as Make44_10_, vehicleinf11_.Model as Model44_10_, vehicleinf11_.ModelYr as ModelYr44_10_, vehicleinf11_.OwnOrLease as OwnOrLease44_10_, vehicleinf11_.PurchaseAmt as Purchas11_44_10_, vehicleinf11_.PurchaseDt as PurchaseDt44_10_, vehicleinf11_.VIN as VIN44_10_ from SAMPLECASE simsamplec0_ left outer join AutoPolicy autopolicy1_ on simsamplec0_.AUTOPOLICYID=autopolicy1_.ID left outer join Address address2_ on autopolicy1_.ID=address2_.AUTOPOLICYID left outer join Coverage coverage3_ on autopolicy1_.ID=coverage3_.AUTOPOLICYID left outer join Customer customer4_ on autopolicy1_.ID=customer4_.AUTOPOLICYID left outer join Communication communicat5_ on customer4_.AUTOPOLICYID=communicat5_.AUTOPOLICYID left outer join DrivingRecord drivingrec6_ on customer4_.AUTOPOLICYID=drivingrec6_.AUTOPOLICYID left outer join AccidentInfo accidentin7_ on drivingrec6_.AUTOPOLICYID=accidentin7_.AUTOPOLICYID left outer join MovingViolations movingviol8_ on drivingrec6_.AUTOPOLICYID=movingviol8_.AUTOPOLICYID left outer join PersInfo persinfo9_ on customer4_.AUTOPOLICYID=persinfo9_.AUTOPOLICYID left outer join GeneralQuestions generalque10_ on autopolicy1_.ID=generalque10_.AUTOPOLICYID left outer join VehicleInfo vehicleinf11_ on autopolicy1_.ID=vehicleinf11_.AUTOPOLICYID where simsamplec0_.AUTOPOLICYID in (?, ?)
When I am using the default value of 1 for fetch size, the query used is
Code:
Hibernate: select simsamplec0_.AUTOPOLICYID as AUTOPOLI1_92_11_, simsamplec0_.sampleWeight as sampleWe2_92_11_, autopolicy1_.ID as ID93_0_, autopolicy1_.EffectiveDt as Effectiv2_93_0_, autopolicy1_.ExpirationDt as Expirati3_93_0_, autopolicy1_.PolicyNumber as PolicyNu4_93_0_, address2_.AUTOPOLICYID as AUTOPOLI1_100_1_, address2_.AddrType as AddrType100_1_, address2_.City as City100_1_, address2_.Country as Country100_1_, address2_.County as County100_1_, address2_.State as State100_1_, address2_.Street as Street100_1_, address2_.Zip as Zip100_1_, coverage3_.AUTOPOLICYID as AUTOPOLI1_101_2_, coverage3_.CoverageCd as CoverageCd101_2_, coverage3_.Deductible as Deductible101_2_, coverage3_.Limit as Limit101_2_, customer4_.AUTOPOLICYID as AUTOPOLI1_94_3_, customer4_.CreditScore as CreditSc2_94_3_, customer4_.FirstName as FirstName94_3_, customer4_.LastName as LastName94_3_, customer4_.TaxId as TaxId94_3_, customer4_.TaxIdTypeCd as TaxIdTyp6_94_3_, communicat5_.AUTOPOLICYID as AUTOPOLI1_95_4_, communicat5_.Email as Email95_4_, communicat5_.Phone as Phone95_4_, drivingrec6_.AUTOPOLICYID as AUTOPOLI1_97_5_, drivingrec6_.AnyAccidentInLast3Years as AnyAccid2_97_5_, drivingrec6_.AnyMovingViolationsInLast3Years as AnyMovin3_97_5_, drivingrec6_.LicensedSince as Licensed4_97_5_, drivingrec6_.LicNumber as LicNumber97_5_, drivingrec6_.LicState as LicState97_5_, drivingrec6_.NumYearsLicensed as NumYears7_97_5_, accidentin7_.AUTOPOLICYID as AUTOPOLI2_13_, accidentin7_.INDEX1 as INDEX1_13_, accidentin7_.INDEX1 as INDEX1_98_6_, accidentin7_.AUTOPOLICYID as AUTOPOLI2_98_6_, accidentin7_.AccidentDescription as Accident3_98_6_, accidentin7_.AccidentTypeCd as Accident4_98_6_, accidentin7_.AtFaultInd as AtFaultInd98_6_, accidentin7_.BodilyInjuriesInd as BodilyIn6_98_6_, accidentin7_.DateofAccident as DateofAc7_98_6_, movingviol8_.AUTOPOLICYID as AUTOPOLI2_14_, movingviol8_.INDEX1 as INDEX1_14_, movingviol8_.INDEX1 as INDEX1_99_7_, movingviol8_.AUTOPOLICYID as AUTOPOLI2_99_7_, movingviol8_.DateofViolation as DateofVi3_99_7_, movingviol8_.Incarceration as Incarcer4_99_7_, movingviol8_.MovingViolationsTypeCd as MovingVi5_99_7_, movingviol8_.ViolationDescription as Violatio6_99_7_, persinfo9_.AUTOPOLICYID as AUTOPOLI1_96_8_, persinfo9_.Age as Age96_8_, persinfo9_.DOB as DOB96_8_, persinfo9_.Employer as Employer96_8_, persinfo9_.Gender as Gender96_8_, persinfo9_.HomeOwner as HomeOwner96_8_, persinfo9_.LengthTimeEmployed as LengthTi7_96_8_, persinfo9_.LengthTimewithPrevEmployer as LengthTi8_96_8_, persinfo9_.MaritalStatusCd as MaritalS9_96_8_, persinfo9_.NumDependents as NumDepe10_96_8_, persinfo9_.NumJobChanges as NumJobC11_96_8_, persinfo9_.Occupation as Occupation96_8_, persinfo9_.YrsAtCurrentResidence as YrsAtCu13_96_8_, generalque10_.AUTOPOLICYID as AUTOPOLI2_15_, generalque10_.INDEX1 as INDEX1_15_, generalque10_.INDEX1 as INDEX1_103_9_, generalque10_.AUTOPOLICYID as AUTOPOLI2_103_9_, vehicleinf11_.AUTOPOLICYID as AUTOPOLI2_16_, vehicleinf11_.INDEX1 as INDEX1_16_, vehicleinf11_.INDEX1 as INDEX1_102_10_, vehicleinf11_.AUTOPOLICYID as AUTOPOLI2_102_10_, vehicleinf11_.AnnualMileage as AnnualMi3_102_10_, vehicleinf11_.Color as Color102_10_, vehicleinf11_.LicensePlateNum as LicenseP5_102_10_, vehicleinf11_.LienHolder as LienHolder102_10_, vehicleinf11_.Make as Make102_10_, vehicleinf11_.Model as Model102_10_, vehicleinf11_.ModelYr as ModelYr102_10_, vehicleinf11_.OwnOrLease as OwnOrLease102_10_, vehicleinf11_.PurchaseAmt as Purchas11_102_10_, vehicleinf11_.PurchaseDt as PurchaseDt102_10_, vehicleinf11_.VIN as VIN102_10_ from SAMPLECASE simsamplec0_ left outer join AutoPolicy autopolicy1_ on simsamplec0_.AUTOPOLICYID=autopolicy1_.ID left outer join Address address2_ on autopolicy1_.ID=address2_.AUTOPOLICYID left outer join Coverage coverage3_ on autopolicy1_.ID=coverage3_.AUTOPOLICYID left outer join Customer customer4_ on autopolicy1_.ID=customer4_.AUTOPOLICYID left outer join Communication communicat5_ on customer4_.AUTOPOLICYID=communicat5_.AUTOPOLICYID left outer join DrivingRecord drivingrec6_ on customer4_.AUTOPOLICYID=drivingrec6_.AUTOPOLICYID left outer join AccidentInfo accidentin7_ on drivingrec6_.AUTOPOLICYID=accidentin7_.AUTOPOLICYID left outer join MovingViolations movingviol8_ on drivingrec6_.AUTOPOLICYID=movingviol8_.AUTOPOLICYID left outer join PersInfo persinfo9_ on customer4_.AUTOPOLICYID=persinfo9_.AUTOPOLICYID left outer join GeneralQuestions generalque10_ on autopolicy1_.ID=generalque10_.AUTOPOLICYID left outer join VehicleInfo vehicleinf11_ on autopolicy1_.ID=vehicleinf11_.AUTOPOLICYID where simsamplec0_.AUTOPOLICYID=?
And regarding the changing of query, I can not change query string. That will be provided as argument. But i tried using pagination , setfirstresult and setmaxresult but it also did not gave much difference in performance.
and again thanks for posting reply :)