PARTITION PROCEDURE — Specifies that a stored procedure is partitioned.
PARTITION PROCEDURE procedure-name ON TABLE table-name COLUMN column-name [PARAMETER position ]
Partitioning a stored procedure specifies that the procedure executes within a unique partition of the database. The partition in which the procedure executes is chosen at runtime based on the table and column specified by table-name and column-name and the value of the first parameter to the procedure. For example:
PARTITION TABLE Employees ON COLUMN BadgeNumber; PARTITION PROCEDURE FindEmployee ON TABLE Employees COLUMN BadgeNumber;
The procedure FindEmployee is partitioned on the table Employees, and table Employees is in turn partitioned on the column BadgeNumber. This means that when the stored procedure FindEmployee is invoked VoltDB determines which partition to run the stored procedure in based on the value of the first parameter to the procedure and the corresponding partitioning value for the column BadgeNumber. So to find the employee with badge number 145303 you would invoke the stored procedure as follows:
clientResponse response = client.callProcedure("FindEmployees", 145303);
By default, VoltDB uses the first parameter to the stored procedure as the partitioning value. However, if you want to use the value of a different parameter, you can use the PARAMETER clause. The PARAMETER clause specifies which procedure parameter to use as the partitioning value, with position specifying the parameter position, counting from zero. (In other words, position 0 is the first parameter, position 1 is the second, and so on.)
The specified table must be a partitioned table and cannot be an export-only or replicated table.