Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In further examples affinity function is denoted as '{...}'. Extracted partition is either concrete number, or query parameter index which will be converted to concrete number later. We will denote first type as "Pn" (e.g. P1, P2), and second as ":INDEX" (e.g. :1, :2). If partition cannot be extracted from condtitioncondition, we will denote it as "ALL". Empty partition set is denoted as "EMPTY".

Equality

For equality we simply apply affinity function to the value.

...

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 } or EMPTY on the other side.

For AND condition there is a special rule. If two sides contain parameters, we cannot simplify them, because final result depend on resolved partitions. If left side contain parameters and right side contain only concrete values, then we can remove concrete values from the left side which are not present on the right side. And vice versa.

Code Block
languagesql
titleExpression AND algebra
linenumberstrue
{(P1}) AND {(P2}) => ()
{(P1, P2}) AND {(P3, P4}) => () 
{(P1, P2}) AND {(P2, P3}) => {(P2})
{(P1}) AND {(ALL}) => (P1)
{(P1, P2}) AND {(ALL}) => (P1, P2)
(P1, P2) AND () => ()

{(:1}) AND {(:2}) => (:1) AND (:2)
{(:1}) AND {(ALL}) => (:1)


{P1}(:1) AND {:2}() => ()

(P1) AND (:2) // Cannot merge as final result depends on concrete value of :2
{=> (P1) AND (:2)
(P1, :1}) AND {(P2}) => (P1, :1) AND (P2)




{1} OR {2}(P1, :1) AND (P2, :2) => (1P1, 2)
{1} OR {ALL} => {ALL}:1) AND (P2, :2)

Ranges on integer types

TODO

...