System startup performance problems(DeviceController.readAll ())

20 views
Skip to first unread message

汤慰生

unread,
May 29, 2014, 3:32:39 AM5/29/14
to openmobs...@googlegroups.com

Hi Sohil,
I now use 2.4 M3, JBOSS server has not restarted more than two months , and today just for maintenance, restart the service , but the question arises
As the number of users is too large, the service has been in the initial process , start takes about three hours to complete .
After checking the source code, open security-hibernate.cfg file :
<property name="show_sql"> false </ property>
Is set to true, displays the SQL statement
Found as follows :
2014-05-29 13:57:44,762 INFO [STDOUT] (main) Hibernate: select device0_.deviceId as deviceId9_, device0_.identifier as identifier9_, device0_.identityId as identityId9_ from openmobster_device device0_
2014-05-29 13:57:45,590 INFO [STDOUT] (main) Hibernate: select identity0_.identityId as identityId2_0_, identity0_.principal as principal2_0_, identity0_.credential as credential2_0_ from openmobster_identity identity0_ where identity0_.identityId =?
........................ ( Consistent quantity and number of users )
2014-05-29 13:58:32,881 INFO [STDOUT] (main) Hibernate: select attributes0_.deviceId as deviceId1_, attributes0_.elt as elt1_, deviceattr1_.attributeId as attribut1_11_0_, deviceattr1_.name as name11_0_, deviceattr1_.value as value11_0_ from openmobster_device_attributes attributes0_ left outer join openmobster_device_attribute deviceattr1_ on attributes0_.elt = deviceattr1_.attributeId where attributes0_.deviceId =?
........................ ( Consistent quantity and number of users )
After checking the source code found in org.openmobster.core.security.device DeviceController.readAll ()

public List <Device> readAll () throws DeviceSecurityException
{
Session session = null;
Transaction tx = null;
try
{
List <Device> allDevices = new ArrayList <Device> ();

session = this.hibernateManager.getSessionFactory () getCurrentSession ().;
tx = session.beginTransaction ();

String query = "from Device";

List devices = session.createQuery (query) setCacheable (true) list ()..;
if (devices! = null)
{
allDevices.addAll (devices);
}

tx.commit ();

return allDevices;
}
catch (Exception e)
{
log.error (this, e);

if (tx! = null)
{
tx.rollback ();
}
throw new DeviceSecurityException (e);
}
}

Here the use of createQuery, using HQL query , hibernate first query the data openmobster_device table , I now table data as 3.8 million data loading time soon , about 4.5S
But do not hibernate joint inquiry , after query the device table data , then a section to query data openmobster_identity, openmobster_device_attributes, openmobster_identity_attributes associated table
Finally, one of the objects packaged into Device
This is a large amount of data limitations hibernate query when
So I want to use createSQLQuery, direct use of JDBC SQL query , but I do not know how to modify String query = "from Device"; HQL statement on unfamiliar .
HQL or modified to allow it to conduct a joint inquiry disposable , rather than as they are now , and finally one to query related properties
I use a database MYSQL 5.6

Thanks

Reply all
Reply to author
Forward
0 new messages