cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Török Péter <>
Subject Wanted: performance tuning hints
Date Mon, 12 Mar 2007 14:40:15 GMT
Sorry for the previous mail, I inadvertently sent it half-ready :-(
I made a small performance test comparing different Cayenne solutions with JDBC solutions.
What I found was that in Insert operations, it is best to use Cayenne data objects (as opposed
to raw SQL queries), while for Update and Delete the case is the opposite. I guess this may
not surprise you :-)
So for Insert, this worked best for me:
public void insertRecords(int count) {
    Date date = new Date();
    for (int index = 1; index <= count; index++) {
        TestData testData = (TestData) context.newObject(TestData.class);
        testData.setCount(new Integer(count - index));
        if (index % 1000 == 0) {

while for Update and Delete, something like this:

public void updateRecords(int lowerLimit, int upperLimit) {
    final SQLTemplate query = new SQLTemplate(TestData.class,
        "update test_data set description = '$desc' where count > $lower and count <
    Map params = new HashMap();
    params.put("desc", nextDescription());
    params.put("lower", new Integer(lowerLimit));
    params.put("upper", new Integer(upperLimit));

Any hints on how to make these methods faster?
Thanks in advance,

  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message