Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 952045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:49:48+00:00 2026-05-15T23:49:48+00:00

I use H2 database for environmental data which contains lots of time series. Time

  • 0

I use H2 database for environmental data which contains lots of time series. Time series are simply measurement values of sensors which are recorded in database periodically (say once per hour).

The data stored in the table:

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

I would like to make range queries against the table, for example:

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

In order to improve performance I would like to build clustered index over dt column, but the thing is, that I haven’t found if H2 supports clustered indexes. Does anybody know if clustered indexes are supported in H2?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:49:49+00:00Added an answer on May 15, 2026 at 11:49 pm

    Short answer: the primary key of your table needs to be of type BIGINT:

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

    In this case, the table is organized using the “dt” column. This is called “clustered index”. The data type TIMESTAMP is not supported, mainly because it also contains nanoseconds. What you could do is store the unix timestamp (milliseconds since 1970) as a BIGINT.

    Long answer: The documentation of how data is stored internally in H2 is poor. I will add the following section to the “performance” documentation of the H2 database. I hope this will clear up things (if not please tell me):

    How Data is Stored Internally

    For persistent databases, if a table is created with a single column primary key of type BIGINT, INT, SMALLINT, TINYINT, then the data of the table is organized in this way. This is sometimes also called a “clustered index” or “index organized table”.

    H2 internally stores table data and indexes in the form of b-trees. Each b-tree stores entries as a list of unique keys (one or more columns) and data (zero or more columns). The table data is always organized in the form of a “data b-tree” with a single column key of type long. If a single column primary key of type BIGINT, INT, SMALLINT, TINYINT is specified when creating the table, then this column is used as the key of the data b-tree. If no primary key has been specified, if the primary key column is of another data type, or if the primary key contains more than one column, then a hidden auto-increment column of type BIGINT is added to the table, which is used as the key for the data b-tree. All other columns of the table are stored within the data area of this data b-tree (except for large BLOB, CLOB columns, which are stored externally).

    For each additional index, one new “index b-tree” is created. The key of this b-tree consists of the indexed columns, plus the key of the data b-tree. If a primary key is created after data has been inserted, or if the primary key contains multiple column, or if the primary key is not of the data types listed above, then the primary key is stored in a new index b-tree.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have compared two queries which fetch some fairly large data from a database
We have an WCF application which uses NHibernate to query data from the database.
I am planning for monitoring application which will use SQL Server 2005/08 database. It
Question: I use System.Data.OracleClient. System.Data.OracleClient requires OracleInstantClient, which are native dll's. So in order
I'm in Asp.net MVC3 environment, and I use Advantage Database 9.1. and I want
MySQL uses the USE database_name to change the active database. Does that work on
When is it best to use database as a session store in PHP? I
I'm working on an email solution in SQL Server ONLY that will use Database
I use H2 Database as DBMS from a remote computer,so I enabled remote access
How can I use a database and PHP sessions to store a user's shopping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.