Ashish
Ashish

Reputation: 3060

How does HSQLDB maintain indexes?

Does anyone has any idea about how does HSQLDB maintain indexes? I could not find any good documentation having details on this. I am maintaining a key value pair type information in hsqldb tables, where the keys and values will consist of multiple columns of an hsqldb table. I would place an index over my key columns, I wish to know if there is any need to separately cache my key-value pairs in a map while app is running or will the hsqldb indexes work in a similar manner and return me the values for keys in O(1) time.

A sample query on my table will look like this:

select col1, col2 from table1 where col3=val3 and col4=val4;

Will an index on col3 and col4 fetch the result on O(1)

Upvotes: 2

Views: 1438

Answers (1)

fredt
fredt

Reputation: 24372

An index such as the one below is used with the given select statement.

CREATE INDEX idx ON table1(col3, col4)

An in-memory hash map could be faster for retrieval as it has less overheads. But you should test first and see if the SELECT speed is adequate for your needs.

Upvotes: 3

Related Questions