Forum: Building VoltDB Applications

Post: VoltDB view behavior

VoltDB view behavior
whtan98
Sep 6, 2011
I've downloaded the VMWare image with VoltDB 1.3.5 and tried out the voter example.
The following query is executed after running the server & client:
select * from v_votes_by_contestant_number order by 1;
CONTESTANT_NUMBER NUM_VOTES
------------------ ----------
1 27181
1 27502
2 3751
2 3700
...

Is the view supposed to have only 1 row for each contestant number ? It seems to be dependent on the parameter
Please enlighten. Thanks
Views are specific to each partition
nshi
Sep 7, 2011
whtan98,

Views in VoltDB are specific to each partition. The view you were looking at does roll-up in each partition, but not across the whole cluster. When you did the SELECT, the returned result was from all partitions. That is why there were multiple rows with the same contestant number.

To get the result you want, you have to do an aggregation on the view. For example,

SELECT CONTESTANT_NUMBER, SUM(NUM_VOTES) VOTES FROM V_VOTES_BY_CONTESTANT_NUMBER GROUP BY CONTESTANT_NUMBER ORDER BY CONTESTANT_NUMBER;

Ning