Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 24854 invoked from network); 21 Jan 2008 14:27:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Jan 2008 14:27:47 -0000 Received: (qmail 11157 invoked by uid 500); 21 Jan 2008 14:27:37 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 11145 invoked by uid 500); 21 Jan 2008 14:27:37 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 11136 invoked by uid 99); 21 Jan 2008 14:27:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Jan 2008 06:27:36 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kuuldor@gmail.com designates 64.233.162.230 as permitted sender) Received: from [64.233.162.230] (HELO nz-out-0506.google.com) (64.233.162.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Jan 2008 14:27:12 +0000 Received: by nz-out-0506.google.com with SMTP id v1so993602nzb.18 for ; Mon, 21 Jan 2008 06:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=J71Fpc+eOnA8XyvZiEslrCElXE05+LFCOXyBYk/Vei8=; b=BCiHNtgBCmU741CE2Gb2l/MYRnGI71keUfbi/ypJgI0QdJ4Es3YhGyUbYFCl1xQAJQCPh35d6pj5lVOO/kvT4TrTGU/NKhPdReWbn66SpORaD9vrCtp40WePCJCzHrLSGdRxblnQAfVaFXWXaKR9QckfRrdO8AxoG7KEUK9NDgI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=oBnTX/t49dg5DoWRism6vih2q3cCe39TF+ltGCVlRZPA/Q+Hs/oc9nuYJhLTfeT5scX9hKIlHFEuBUw9YM36w1BO/aZSkTp5rrmGQhFotxxkbfcL9+vyDqEdD30Qfng9ItsC03cybM5gECtTzzOFQ7yKzw+0gcCldA3AegjPsTI= Received: by 10.142.49.4 with SMTP id w4mr3163210wfw.185.1200925636905; Mon, 21 Jan 2008 06:27:16 -0800 (PST) Received: by 10.142.135.20 with HTTP; Mon, 21 Jan 2008 06:27:16 -0800 (PST) Message-ID: Date: Mon, 21 Jan 2008 22:27:16 +0800 From: kuuldor To: users@openjpa.apache.org Subject: Weird Performance Problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org Hi everybody, I'm trying to use OpenJPA in my new project, but when I do some experiments I encounter a very low performance in inserting records into database. My situation is like this: Database is derby 10.2 A very simple table 'account' having a auto-increment ID, and a 'name' field of varchar(16), and an 'fullname' field of varchar(32) and 'descript' of varchar(255). Here is the create table SQL: create table account (id integer not null generated always as identity, name varchar(16) not null unique, fullname varchar(32), descript varchar(255), constraint Account_Primary_ID primary key (id)); My persistence.xml is like this: org.apache.openjpa.persistence.PersistenceProviderImpl test.Account And the Entity Class is: package test; import java.io.Serializable; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import javax.persistence.*; @Entity() @Table(name="ACCOUNT") public class Account implements Serializable { //default serial version id, required for serializable classes. private static final long serialVersionUID = 1L; private Integer id; private String descript; private String fullname; private String name; public Account() { } @Id() @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="ID", unique=true, nullable=false, precision=10) public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } @Basic() @Column(name="DESCRIPT", length=255) public String getDescript() { return this.descript; } public void setDescript(String descript) { this.descript = descript; } @Basic() @Column(name="FULLNAME", length=32) public String getFullname() { return this.fullname; } public void setFullname(String fullname) { this.fullname = fullname; } @Basic() @Column(name="NAME", unique=true, nullable=false, length=16) public String getName() { return this.name; } public void setName(String name) { this.name = name; } public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof Account)) { return false; } Account castOther = (Account)other; return new EqualsBuilder() .append(this.getId(), castOther.getId()) .isEquals(); } public int hashCode() { return new HashCodeBuilder() .append(getId()) .toHashCode(); } public String toString() { return new ToStringBuilder(this) .append("id", getId()) .toString(); } } My test is to insert 1000 records into the table. The test code is like this: private static void insertJPA() throws DAOException, SQLException { DAOFactory daoF = new DAOFactory(); AccountDao accountDao = daoF.getAccountDao(); System.out.println(new java.util.Date().toString()); for (int i = 0; i<1000; i++) { TransactionProxy tran = accountDao.beginTransaction(); Account newuser = new Account(); newuser.setName("user" + i); //newuser.setFullname("User No. " + i); //newuser.setDescript("Common user"); accountDao.insert(newuser); accountDao.commitTransaction(tran); } } This test can only finish in about 1min 30sec, equals to 11rec/sec. If I get rid of the fullname and descript fields from the table. The time can be shorten to 32sec. But it still be quite slow. I've done the test with BEA Kodo which is based on OpenJPA. Kodo can insert the 1000 record in 9sec, about 10 times faster than OpenJPA. And I did not do any optimization for Kodo. So anybody knows why the performance of OpenJPA is so slow? Or how to optimize OpenJPA to achieve the performance near Kodo? Thanks a lot.