Hello Castor team.
Sorry for the big letter.

I performed some benchmarks of Castor JDO and
got really bad results. The test case performed selection
of 100, 1000, 5000 and 10000 objects from the database (all results are in
milliseconds).

The code snapshot:

                                
        db = _jdo.getDatabase();
        db.begin();
        query = db.getOQLQuery( "SELECT c FROM " 
        + Product.class.getName() + " c WHERE c.id < " + rowsNum );
                                                t4 =
System.currentTimeMillis();
        results = query.execute();
                                                t5 =
System.currentTimeMillis();
        while ( results.hasMore() )
        {
            prod = (Product) results.next();
        }
                                                t6 =
System.currentTimeMillis();
        db.commit();
                                                t7 =
System.currentTimeMillis();
        db.close();

        System.out.println( "execQuery:" + (t5-t4) );
        System.out.println( "loop:" + (t6-t5) );
        System.out.println( "commitTrans:" + (t7-t6) );



Results for 100 rows:
        execQuery:        605 
        loop:               71 
        commitTrans:        70

Results for 1000 rows:
        execQuery:        610 
        loop:           1112 
        commitTrans:      681

Results for 5000 rows:
        execQuery:          601 
        loop:           25246 
        commitTrans:       15212

Results for 10000 rows:
        execQuery:            761 
        loop:           105853 
        commitTrans:         65674

As you can see, the times for 100 and 1000 rows are "reasonable" while for 
5000 or 10000 is too slow (comparing to direct JDBC).

So there are number of questions that the results raise:

Why looping over 1000 rows is 25 times faster than over 5000 rows (it should
by 1:5)?
How can I reduce looping time & commit time (may be there is some
settings/parameters)?
Why QueryResultsEnum is not serializable object, so there will no need to
copy it to another container?

Any suggestion/correction/answer is highly appreciated.

Additional info:
        
mapping for the class:

        <class name="Product" identity="id">
    
                <map-to table="prod" xml="product" />
                
                <field name="id" type="integer">
                        <sql name="id" type="integer" />
                        <bind-xml name="id" node="attribute"/>
                </field>

                <field name="name" type="string">
                        <sql name="name" type="char" />
                        <bind-xml name="name" node="element" />
                </field>

                <field name="price" type="integer">
                        <sql name="price" type="integer" />
                        <bind-xml name="price" node="attribute" />
                </field>

        </class>

Class definition:

public class Product
{
    private int     _id;
    private String  _name;
    private int     _price;

    public Product(){}

    public int getId()
    {
        return _id;
    }

    public void setId( int id )
    {
        _id = id;
    }

    public String getName()
    {
        return _name;
    }

    public void setName( String name )
    {
        _name = name;
    }

    public int getPrice()
    {
        return _price;
    }

    public void setPrice( int price )
    {
        _price = price;
    }
}


Best regards,
        Mark.

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to