H2 Database: Support for Clustered Indexes

I use the H2 database for environmental data, which contains many time series. Time series are simply measured values ​​of sensors that are periodically recorded in a database (say, once an hour).

Data stored in the table:

CREATE TABLE hydr
(dt timestamp
,value double
,sensorid int)

I would like to make range queries on a table, for example:

select * from hydr
where dt between '2010-01-01' and '2010-10-01'

To improve performance, I would like to create a clustered index on the dt column, but the fact is that I did not find if H2 supports clustered indexes. Does anyone know if cluster indexes are supported in H2?

+3
source share
1 answer

Short answer: the primary key of the table must be of type BIGINT:

CREATE TABLE hydr(dt bigint primary key, value double, sensorid int);

"dt". " ". TIMESTAMP , , . unix ( 1970 ) BIGINT.

: , H2, . "" H2. , ( ):

, BIGINT, INT, SMALLINT, TINYINT, . " " " ".

H2 b-. b- ( ) ( ). " b" long. BIGINT, INT, SMALLINT, TINYINT, b- . , , BIGINT, b-. ( BLOB, CLOB, ).

"b- ". b- b-. , , , b- .

+9

Source: https://habr.com/ru/post/1756059/


All Articles