[ https://issues.apache.org/activemq/browse/CAMEL-2982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=60837#action_60837 ]
Christian Mueller commented on CAMEL-2982: ------------------------------------------ Running the [JpaTest.java|http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java?view=markup], we can see the following log comments: {code} ... 22143 camel TRACE [main] openjpa.jdbc.SQL - <t 533209608, conn 232003191> executing prepstmnt 957929250 SELECT t0.address FROM SendEmail t0 WHERE t0.id = ? [params=(long) 0] 22144 camel TRACE [main] openjpa.jdbc.SQL - <t 533209608, conn 232003191> [1 ms] spent 22244 camel TRACE [main] openjpa.jdbc.SQL - <t 533209608, conn 824055564> executing prepstmnt 113256058 SELECT SEQUENCE_VALUE FROM OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE WITH RR [params=(int) 0] 22246 camel TRACE [main] openjpa.jdbc.SQL - <t 533209608, conn 824055564> [1 ms] spent 22326 camel TRACE [main] openjpa.jdbc.SQL - <t 533209608, conn 824055564> executing prepstmnt 1865566999 UPDATE OPENJPA_SEQUENCE_TABLE SET SEQUENCE_VALUE = ? WHERE ID = ? AND SEQUENCE_VALUE = ? [params=(long) 151, (int) 0, (long) 101] 22338 camel TRACE [main] openjpa.jdbc.SQL - <t 533209608, conn 824055564> [11 ms] spent 22384 camel TRACE [main] openjpa.jdbc.SQL - <t 533209608, conn 957509009> executing prepstmnt 1211729930 INSERT INTO SendEmail (id, address) VALUES (?, ?) [params=(long) 101, (String) f...@bar.com] 22402 camel TRACE [main] openjpa.jdbc.SQL - <t 533209608, conn 957509009> [18 ms] spent ... {code} using persist instead of merge, you can see the following output (note on the missing 'SELECT t0.address FROM SendEmail t0 WHERE t0.id = ?'): {code} ... 13837 camel TRACE [main] openjpa.jdbc.SQL - <t 1954210149, conn 272890728> executing prepstmnt 1989444474 SELECT SEQUENCE_VALUE FROM OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE WITH RR [params=(int) 0] 13839 camel TRACE [main] openjpa.jdbc.SQL - <t 1954210149, conn 272890728> [0 ms] spent 13946 camel TRACE [main] openjpa.jdbc.SQL - <t 1954210149, conn 272890728> executing prepstmnt 1102050319 UPDATE OPENJPA_SEQUENCE_TABLE SET SEQUENCE_VALUE = ? WHERE ID = ? AND SEQUENCE_VALUE = ? [params=(long) 251, (int) 0, (long) 201] 13958 camel TRACE [main] openjpa.jdbc.SQL - <t 1954210149, conn 272890728> [12 ms] spent 14006 camel TRACE [main] openjpa.jdbc.SQL - <t 1954210149, conn 568097598> executing prepstmnt 436762492 INSERT INTO SendEmail (id, address) VALUES (?, ?) [params=(long) 201, (String) f...@bar.com] 14023 camel TRACE [main] openjpa.jdbc.SQL - <t 1954210149, conn 568097598> [16 ms] spent ... {code} Christian > camel-jpa should support an option to switch from EntityManager.merge(entity) > to EntityManager.persist(entity) > -------------------------------------------------------------------------------------------------------------- > > Key: CAMEL-2982 > URL: https://issues.apache.org/activemq/browse/CAMEL-2982 > Project: Apache Camel > Issue Type: Improvement > Components: camel-jpa > Affects Versions: 2.4.0 > Environment: All > Reporter: Christian Mueller > Assignee: Christian Mueller > Fix For: 2.5.0 > > > If you use a 'heavy' normalized database schema, the switch from > EntityManager.merge(entity) to EntityManager.persist(entity) could bring a > performance boost. > The reason is, that by using EntityManager.merge(entity) the EntityManager > will query the database for each entity if this entity already exists in the > database. EntityManager.persist(entity) doesn't query the database before the > entity is persisted. > In our case, the entities are all new entities, if the Id is null and we > think we could improve our throughput with this improvement. > Christian -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.