For VoltDB, while creating the table, I am using primary key to prevent content violation. This creates primary key index automatically which is a balance tree. I have also create Hash index for the tables and I want to use hash index and not to use primary key index. Is there any setting that I can make to use the Hash index while execution of queries.
VoltDB uses a convention to determine whether to use a red-black tree index or a hash index. The convention is to include the substring "hash" (case-insensitive) within the name of the index. It can be a prefix, suffix, or somewhere in the middle of the name.
In my experience, since the index is entirely in-memory, the is very little difference in performance between a tree and hash index. It may be worthwhile to try it both ways and compare the performance vs. space usage to decide which is best.
Also, there are a few syntax styles for declaring the primary key of a table. You do not have to give it a name, but you can, which would allow you to declare whether you want it to be a tree or hash index. There should be no need to create duplicate indexes simply because the primary key index was not as you wanted it. Below are two examples:
CREATE TABLE Version (
Major SMALLINT NOT NULL,
Minor SMALLINT NOT NULL,
baselevel INTEGER NOT NULL,
ReleaseDate TIMESTAMP,
CONSTRAINT Version_Hash_Idx PRIMARY KEY
(Major, Minor, Baselevel) -- hash index
);
CREATE TABLE Version (
Major SMALLINT NOT NULL,
Minor SMALLINT NOT NULL,
baselevel INTEGER NOT NULL,
ReleaseDate TIMESTAMP,
PRIMARY KEY (Major, Minor, Baselevel) -- default tree index
);