-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: update performance
PostPosted: Mon Oct 20, 2008 6:50 am 
Beginner
Beginner

Joined: Thu Jun 14, 2007 4:33 am
Posts: 39
Hibernate version:
3.3.1.GA
Spring version:
2.5.4
DB
postgresql 8.2.4

im planing to do a monthly update on some tables. there are several 100.000 rows to be updated and im using the code below. the first 10.000 rows update in about 5 minutes (including data-export from a datasource using pagination), but after that the update slows down doing only 1 or 2 updates per second!

doImport is called with 1000 records per call, so each transaction 1000 updates should happen.

the database isnt busy at all and there is also enough memory.
debugging my application i assured that only q.executeUpdate(); takes a lot of time to execute allthough the database is just waiting for some work..

any suggestions where to search for the bottleneck?

Code:
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void doImport(List<Permission> permission, String source) {
  for (Permission p: permissions) {
    permissionEmailDao.updatePermissions p.costumernumber, p.email, p.newsletter, source;
    count ++;
               
    if (count > 20) {
      this.m_sf.currentSession.flush();
      this.m_sf.currentSession.clear();
      count = 0;
   } 
  }
}


and the dao:
Code:
private String subquery = "select id from "+ persistentClass.getName() +"  where person.costumer_number = :thenumber";
    private String update = "update " + persistentClass.getName() +
                                " set permissionStandAloneEmailFlag = :v1 , " +
                                "permissionNewsletterFlag = :v2, " +
                                "source = :dsd " +
                            "where id in ( " + subquery+ " )" ;

    public void updatePermissions(String costumerNumber, Integer permissionStandAloneEmailFlag, Integer permissionNewsletterFlag, DataSourceDescriptor dsd) {

        q = this.getSession().createQuery(update);
        q.setInteger("v1", permissionStandAloneEmailFlag);
        q.setInteger("v2", permissionNewsletterFlag);
        q.setString("thenumber", costumerNumber);
        q.setParameter("dsd", dsd);

        q.executeUpdate();

    }


the generated sql:
Code:
update dwh_test.PERMISSION_EMAIL set PERMISSION_STANDALONE_EMAIL_FLAG=?, PERMISSION_NEWSLETTER_FLAG=?, SOURCE=? where id in (select permission1_.id from dwh_test.PERMISSION_EMAIL permission1_, dwh_test.PERSON person2_ where permission1_.PERSON=person2_.id and person2_.COSTUMER_NUMBER=?)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.