Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-08 Thread Lukas Eder
I'll tune in here to provide you with some background info from the jOOQ side. When Markus used jOOQ to *inline* bind values (e.g. WHERE foldermap.parent IN (1, 2, 3, 4)), the query ran in an acceptable time on my machine - around 1/2s. In the latter query, jOOQ renders bind values as question

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-08 Thread Markus Fengler
Hi Lukas, you are right. Now I did four tests. First with inline (e.g. where foldermap.parent in (1,2,3,4,...)) - the query takes less than 2 seconds to finish. Second with indexed parameters (e.g. where foldermap.parent in (?,?,?,?,...)) - the query takes arount 37 seconds to finish. Third

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-08 Thread Noel Grandin
Hi Thanks for the updated test case. I've looked into this, and the situation is thusly: We have special case optimised code for handling IN (1,2,3) queries. Unfortunately, for IN (?,?,?) queries the optimised code does not get used because we at the point in time we run the optimiser, the

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-08 Thread Lukas Eder
Hello, 2013/10/8 Noel Grandin noelgran...@gmail.com Hi Thanks for the updated test case. I've looked into this, and the situation is thusly: We have special case optimised code for handling IN (1,2,3) queries. Unfortunately, for IN (?,?,?) queries the optimised code does not get used

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-08 Thread Noel Grandin
On 2013-10-08 11:42, Lukas Eder wrote: In SQL, some expressions are deterministic (in the Oracle sense of the word), and some expressions are constant. Both expression attributes propagate through expressions. If a function F is deterministic, then F(A, B) is deterministic only if both A

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-08 Thread Markus Fengler
Hi, I'm really impressed by the your support. Thank you for this. @Noel: If it's to hard to implement then don't think to long about it. As you said it's a special case (although I like it to use the jOOQ Function `select * from something where x in (Collection of Ids)', but it's not to hard

[h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-08 Thread Thomas Mueller
Hi, Would it be possible to disable generating CAST? If the bind variable is set using PreparedStatement.setLong, I don't see why CAST would be needed. Of course support for superfluous CAST (or any deterministic function on a parameter) could be implemented in H2, but so far it wasn't needed,

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-08 Thread Lukas Eder
2013/10/8 Thomas Mueller thomas.tom.muel...@gmail.com Hi, Would it be possible to disable generating CAST? If the bind variable is set using PreparedStatement.setLong, I don't see why CAST would be needed. This is why:

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-08 Thread Thomas Mueller
Hi, I see. Maybe it would make sense to add a special case for CAST(? AS type) in the parser, so that it's still a parameter, but with a specific type. I will try. Regards, Thomas On Tue, Oct 8, 2013 at 7:39 PM, Lukas Eder lukas.e...@gmail.com wrote: 2013/10/8 Thomas Mueller

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-08 Thread Thomas Mueller
Hi, According to a simple test case, H2 is already using an index when using an unnecessary CAST. So I'm not sure yet what the problem is for your case. Could you run the query with explain and post the query plan? Example: Connection conn = DriverManager.getConnection(jdbc:h2:mem:); Statement

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-07 Thread Noel Grandin
I don't do Maven (because, for example, like now when it can't connect to some server somewhere and so I can't get the project working). But if you create me a standalone project will all of the necessary dependencies included, I can take a look at this problem. On 2013-10-06 22:27,

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-07 Thread Markus Fengler
Hi Noel, no problem. I've created a new example. You can download it here: http://jmlp.volans.uberspace.de/ftp/H2Issue.zip Am Montag, 7. Oktober 2013 15:32:19 UTC+2 schrieb Noel Grandin: I don't do Maven (because, for example, like now when it can't connect to some server somewhere and so

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-07 Thread Thomas Mueller
Hi, I guess the query is slow for some reason, possibly because there is no index. Did you already check the documentation at http://h2database.com/html/performance.html#explain_plan ? Regards, Thomas On Sun, Oct 6, 2013 at 10:27 PM, Markus Fengler nar...@googlemail.comwrote: Hi, I want to

Re: [h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-07 Thread Markus Fengler
Hi Thomas, I don't think it's slow because of a missing index. If I use the inline statement its fast. Did you tried the example? Am Montag, 7. Oktober 2013 21:35:16 UTC+2 schrieb Thomas Mueller: Hi, I guess the query is slow for some reason, possibly because there is no index. Did you

[h2] PreparedStatement with a lot of indexed Parameters hangs up and takes CPU - but there is no error message

2013-10-06 Thread Markus Fengler
Hi, I want to get a ResultSet and the query contains a lot of Parameters. If I use an inline Query then it works but if I use a PreparedStatement with indexed Parameters there seems to be a problem. Here is an example for this strange behaviour. You can download the whole Example as maven