YZh
YZh

Reputation: 9

Is there a difference in RAM usage between querying tables directly and querying a view in H2 database?

I can't decide what to use (direct SQL query or query to view) in order to decrease RAM usage.

Is there a difference in RAM usage between querying tables directly and querying a view in H2 database? What are requirements for RAM in H2 database?

I get an org.h2.jdbc.JdbcSQLNonTransientException caused by org.h2.mvstore.MVStoreException: Reading from file sun.nio.ch.FileChannelImpl@6afd7e5d failed at 8638329 (length 6049792), read 0, remaining 3072 [2.2.224/1] very often.

Database is corrupted.

I think the problem is caused by insufficient amount of free RAM.

The amount of RAM is limited and will be limited. I don't know how to prevent database corruption.

Here is an addition to my question.

I have a desktop application written in Java (JavaFX + Spring Boot + H2 database). This application uses an embedded db. This application can use H2 Server but uses the embedded db.

This application uses an SQL view which joins 23 tables and other views. I can't create a materialized view because H2 database doesn't support this type of views.

This application have many users. Users databases have different amount of data. The problem is that I don't have an access to these databases. I have only messages about problems with databases.

Users computers have 8Gb of RAM.

I know that the default -Xmx value in OpenJDK is one-fourth of the physical memory for non-server machines. I decided to use more RAM (-Xmx4G) but errors with databases take place periodically.

Today I have recieved the message below.

Caused by: org.h2.jdbc.JdbcSQLNonTransientConnectionException: File corrupted while reading record: "... .mv.db". Possible solution: use the recovery tool [90030-224]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:690)
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
    at org.h2.message.DbException.get(DbException.java:212)
    at org.h2.mvstore.db.Store.convertMVStoreException(Store.java:163)
    at org.h2.mvstore.db.Store.<init>(Store.java:142)
    at org.h2.engine.Database.<init>(Database.java:326)
    at org.h2.engine.Engine.openSession(Engine.java:92)
    at org.h2.engine.Engine.openSession(Engine.java:222)
    at org.h2.engine.Engine.createSession(Engine.java:201)
    at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)
    at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)
    at org.h2.Driver.connect(Driver.java:59)
    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
    at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
    at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
    at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
    at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:733)
    at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:712)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    ... 1 common frames omitted
Caused by: org.h2.mvstore.MVStoreException: Double mark: 357/16f [2-32, 39-34c, 357-3c6, 3ca-3d2, 3da-3e9, 3ee-4d7, 4fc-520, 532-56a, 6ee-] [2.2.224/6]
    at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
    at org.h2.mvstore.FreeSpaceBitSet.markUsed(FreeSpaceBitSet.java:184)
    at org.h2.mvstore.RandomAccessStore.markUsed(RandomAccessStore.java:75)
    at org.h2.mvstore.RandomAccessStore.readStoreHeader(RandomAccessStore.java:333)
    at org.h2.mvstore.FileStore.start(FileStore.java:916)
    at org.h2.mvstore.MVStore.<init>(MVStore.java:289)
    at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
    at org.h2.mvstore.db.Store.<init>(Store.java:133)
    ... 17 common frames omitted

The question was "Is there a difference in RAM usage between querying tables directly and querying a view in H2 database?".

May I get any answer to this question?

If I get any comment about MVStoreException it would be useful too.

Thanks in advance.

Upvotes: 0

Views: 59

Answers (0)

Related Questions