How does partitioning work
Jan 23, 2011
How does voltdb find out that a transaction is for a particular partition?
Ryan, Thanks for your reply.
This explains how application can instruct that stored procedure is for single partition.
What I want to know more is that incase a table is partitioned into 10 different partitions, now when we call a procedure with particular value
how it knows that it has to go which partition out of the 10 partitions.
1. Does SQL Engine evaluates at execution time or it is the job of optimizer?
2. How this logic works?
I understood that there is function to which value of partitioning parameter is passed and you get the partition on which stored procedure needs to run.
How does this function calculate?
1. Is there a system table which maintains the lower and upper bounds of each partition tables?
2. If yes, how these bounds are decided, does it get decided when the table gets created?
Currently, the mapping function is a simple hash.
You can find the code here:
EDIT: We've since switched to GitHub. New link: https://github.com/VoltDB/voltdb/blob/master/src/frontend/org/voltdb/TheHashinator.java
1. Understood that data will be distributed in partitions for all inserts if there in procedure.
2. Now queries (Select statements) in Java procedure with '=' in where clause for Partition key can also select the particular partition.
1. How the partition selection decision is done for queries which use operaters like '>' or '<'. For '>' the data can span across partitions, so will the query has to span across multiple partitions?
There is a good description of single-partition and multi-partition stored procedures in our online documentation at DesignProc#designappsinglesitesp
Your SQL will determine if a stored procedure can be single-partition. When SELECTing from a partitioned table, if your SQL doesn't have an exact equality check in the WHERE clause ("... where partition_column = ? ...") VoltDB must check all partitions in the system. Therefore the '>' and '<' operators on partitioned tables will result in multi-partition stored procedures.