Hi,

Sometimes we have noticed that executing a query which calls a user-defined 
table takes longer as expected when multiple instances calls this.
We have got a multi threaded server application which has got multiple 
database connections to different database files using the properties: 
FILE_LOCK=FILE;MV_STORE=FALSE . 

We have something like the example:

import org.h2.tools.SimpleResultSet;
...
public static ResultSet simpleResultSet() throws SQLException {
    SimpleResultSet rs = new SimpleResultSet();
    rs.addColumn("ID", Types.INTEGER, 10, 0);
    rs.addColumn("NAME", Types.VARCHAR, 255, 0);
    rs.addRow(0, "Hello");
    rs.addRow(1, "World");
    return rs;
}

CREATE ALIAS SIMPLE FOR "org.h2.samples.Function.simpleResultSet";
CALL SIMPLE();


To prevent concurrency issues I added the synchronized keyword to the 
method like this:
public *synchronized* static ResultSet simpleResultSet() throws SQLException

I am not able to reproduce the problem in a test case at the moment, but we 
see that execting the query with synchronized takes longer than without 
synchronized. 

Does someone have got an explanation for this? 
Is it a bad idea of me to prevent concurrency issues using the synchronized 
keyword?
Or do you think it is not possible that there are 2 instances executing a 
query which calls the user-defined table at the same time?






-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to