2009/12/16 Chuck Remes <[email protected]>: > > On Dec 16, 2009, at 4:20 AM, Istvan Soos wrote: > >> Hi, >> >> I've read somewhere in the docs that h2 has a table lock on writes - >> and while the write is locking, there is no concurrent read. Is it >> true that the writes will lock the reading threads too? What is the >> best way to achieve lock-less reading performance? I care less if the >> writes do lock the tables from other writes... >> > > Take a look at LOCK_MODE. > > http://www.h2database.com/html/grammar.html?highlight=LOCK_MODE&search=lock_mode#set_lock_mode > > It sounds like you want dirty reads which is what you get with 'SET LOCK_MODE > 0'. You can also set it in your connection URL: > > "jdbc:h2:mem:test;LOCK_MODE=0"
If you are using the JDBC API you can control the locking mode from you code directly at a much finer granularity. If you know what you are doing you can set the transaction isolation level to READ_UNCOMMITTED. This speeds things up tremendously. You can use this both when reading and writing. Just call conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); But be warned that you must tightly control you interactions with the DB if you do this. -- Cheers, Mikkel -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
