...
Apache Ignite supports only hash-based sharding, so partition could be extracted only from equality conditions.
In further examples affinity function is denoted as '{...}'. Extracted partition is either concrete number, or query argument indexparameter index which will be converted to concrete number later. We will denote first type as "NPn" (e.g. 1P1, 2, 3P2), and second as ":NINDEX" (e.g. :1, :2). If partition cannot be extracted from condtition, :3).
...
we will denote it as ALL.
For equality we simply apply affinity function to the value.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SELECT * FROM emp WHERE emp.id = 100
=> {id=100} => P1 |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SELECT * FROM emp WHERE emp.id = :1
=> {id=:1} => :1 |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SELECT * FROM emp WHERE emp.id != 100
=> {name!=100} => (ALL) |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SELECT * FROM emp WHERE emp.name = :1
=> {name=:1} => (ALL) |
IN condition with list of values results in a merged list of affected partitions. IN condition with nested SELECT statement will not be supported for now.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
SELECT * FROM emp WHERE emp.id IN (100, :1) => ({name=100}, {name=:1}) => (P1, :1) |
Every WHERE expression can be represented as sequence conjunctive expressions separated by disjunctions. For two OR
...
expressions we return disjunctive set. For AND expressions we return conjunctive set. Concrete partitions can be merged together. Partition placeholders can only be merged with {ALL} on the other side.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{P1} AND {P2} => ()
{P1, P2} AND {P3, P4} => ()
{P1, P2} AND {P2, P3} => {P2}
{P1} AND {ALL} => (P1)
{P1, P2} AND {ALL} => (P1, P2)
{:1} AND {:2} => (:1) AND (:2)
{:1} AND {ALL} => (:1)
{P1} AND {:2} => P1 AND (:2) // Cannot merge as final result depends on concrete value of :2
{P1, :1} AND {P2} => (P1, :1) AND (P2)
{1} OR {2} => (1, 2)
{1} OR {ALL} => {ALL} |
TODO
...
TODO
TODO
TODO
TODO
...