Versions Compared

Key

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

...

Code Block
languagesql
titleOR algebra
linenumberstrue
(P1) OR (P2) => (P1, P2)
(P1) OR (ALL) => (ALL)
(P1) OR () => (P1)
(P1, P2) OR (P2, P3) => (P1, P2, P3)


(:1) OR (:2) => (:1, :2)
(P1, :1) OR (P2, :2) => (P1, P2, :1, :2)

Joins

Joins represent complex case to analyze. But it is very common, so it is crucial to support them as well.

Important observations:

  1. There are two supported types of joins: INNER and LEFT OUTER. Others are either rewritten (RIGHT OUTER) or unsupported (FULL OUTER)
  2. LEFT OUTER join is not commutative. If we found affinity expression on any table to right of "LEFT OUTER" word, this doesn't help us reduce result set anyhow. Hence, we can replace them with (ALL) safely.
  3. For REPLICATED caches without we define special term (ANY). It has one property: can be merged with any other expression safely.

    Code Block
    languagesql
    titleANY algebra
    linenumberstrue
    (P1, :2) AND (ANY) => (P1, :2)
    (P1, :2) OR (ANY) => (P1, :2)


  4. TODO


Flow:

  1. Create a list of involved caches:

    Code Block
    languagejava
    titleOR algebra
    linenumberstrue
    class TableDescriptor {
        String cacheName;
        String affColumnName; 
    
    
        // PARTITIONED or REPLICATED
        CacheMode cacheMode; 
    
    
        // Actual affinity function, needed to compare two tables in JOIN
        AffinityFunction affinityFunc;
    
    
    	// Custom affinity: node filter OR not RendezvousAffinityFunction OR custom AffinityKeyMapper
        boolean customAffinity; 
    
    
        // If after left join.
        boolean replaceWithAll;
      
        // If REPLICATED with non-custom affinity, so relevant data is everywhere.
        boolean replaceWithAny;
    }


  2. If RIGHT 

Query Rewrite

Subqueries

TODO

...