Back Home

Getting Started

Creating a Table

Primary Keys

Primary key's can be added as a constraint on the create table

CREATE TABLE contestants
(
  contestant_number INTEGER     NOT NULL
, contestant_name   VARCHAR(50) NOT NULL
, CONSTRAINT PK_contestants PRIMARY KEY
  (
    contestant_number
  )
);
 
-- votes table holds every valid vote.
--   voters are not allowed to submit more than <x> votes, x is passed to client application
CREATE TABLE votes
(
  phone_number       BIGINT     NOT NULL
, state              VARCHAR(2) NOT NULL
, contestant_number  INTEGER    NOT NULL
);

Indexes

Creating an index on a table makes read access to the table faster when using the columns of the index as a key. Note that VoltDB creates an index automatically when you specify a constraint, such as a primary key, in the CREATE TABLE statement.

  • voltdb can create an index on a column or an expression
     
    CREATE INDEX flightTimeIdx ON FLIGHT ( departtime );
    CREATE UNIQUE INDEX FlightKeyIdx ON FLIGHT ( airline, flightID );

Note: annoyingly auto_increment is not supported. As documented on the blog it is possible to default the index and have a simple (java) stored procedure get and increment the index value

Best Practice

  • Varchars out-of-line with the table data and so looking up each varchar is a level of indirection. If you can type your columns, you might see an improvement.

Monitoring and Admin

Monitoring and admin ports can be modified on the command line or in a deployment.xml file

 voltdb create mycatalog.jar -l ~/license.xml \
         -d deployment.xml -H serverA \
         --client=12345

https://voltdb.com/docs/AdminGuide/HostConfigPortOpts.php

Receiving Json from DB

VoltDB has it's own json interface to receive json results from db queries http://voltdb.com/docs/UsingVoltDB/ProgLangJson.php#JsonIntro

 
voltdb_notes.txt · Last modified: 2014/06/26 06:08 by root
 
RSS - 200 © CrosswireDigitialMedia Ltd