[h2] "Unique index or primary key violation" at concurrent insers (MULTI_THREADED)

2016-12-08 Thread Anatolii K
Hi I've attached test which generates the exception if MULTI_THREADED=1: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.TRAN"; SQL statement: INSERT INTO tran (id) values(?) [23505-193] at

Re: [h2] Re: Very slow calculateCost

2016-12-08 Thread Christian MICHON
Thanks for clarifying. So you've no control on the database DDL and no control on the query (as it is a generic query for an API). My usual practice for long API is to at least split the internal elements into subqueries and only compile the result at the end in the business logic server

Re: [h2] Re: Very slow calculateCost

2016-12-08 Thread itineric
Yes it is an obfuscated real database as I mentionned it when I attached the files. The database is designed to trace all actions performed on an application. The database design is what it is and is mostly optimized to store/restore particular data fastly. The use case of this query is that the

Re: [h2] Re: Very slow calculateCost

2016-12-08 Thread Christian MICHON
I beg to differ: I ran the DDL into DBVisualizer (references mode, circular view) and from the look of it this is a real database with obfuscated names. Redesigning the database is not an option if it's not from the original author: the query itself has to be redesigned and this leads to the

Re: [h2] Re: Very slow calculateCost

2016-12-08 Thread Steve McLeod
Your query is extreme. Hundreds of joins, dozens of nested selects. Way too big, and way too complicated. You'll never get any decent performance with a query like that, nor will you ever be able to analyse and understand the reasons for the performance problems. The solution to your problem