Query times using Tamino API for Java

I have a small database (“mydb”) with about 3000 records. I was experimenting with the Java API by making a simple query interface.

My querying code is as follows:

            long start = System.currentTimeMillis();
            // return all docs
            TXQuery query = TXQuery.newInstance("for $a in input()/mydb return $a");
            TResponse response = xmlObjectAccessor.xquery(query, 10);
            System.out.println((((double) (System.currentTimeMillis() - start)) / 1000) + "s.");

Now when I run this query, it takes about 100 seconds to execute.

When I run the same query using the Tamino Interactive Interface with a result size of 16, the results are displayed within a couple of seconds.

I would like to know two things:
1. Why is there such a huge difference in the time taken?

2. In the Java code, does the query execution time depend on the result size parameter supplied (10 in my code)? For eg, what if I used the method xquery(TXQuery query) instead of xquery(TXQuery query, int quantity)? Would it take longer for it to execute the query? (the result set would contain 3000 records)

The point is that when I make queries that return a lot of records, I want to be able to get the first set of results quickly. I don’t mind if it takes some time to get each subsequent result set.

What is the best way to do this using the Java API?

Have a look at the setLockMode() method of the TConnection class. I’m a total newbie, but I read somewhere that if you set it to unprotected


then this stops Tamino from locking every single record for the duration of the query. The locking takes a LONG time.