4 Replies Latest reply on Apr 29, 2015 11:19 AM by Mark Addleman

    Opportunity for planner optimization?

    Mark Addleman Master

      I'm starting to play with the Cassandra translator and learning about the wierdnesses of Cassandra queries at the same time.  I've discovered that AND clauses pretty much require an "ALWAYS FILTER" clause added to the CQ because it won't do an intersection of two indexed columns.  So, my plan is to enhance the Cassandra translator to rewrite SQL of the form

      select * from x where y=a and z=b

      to the form

      select * from x where y=a

      intersect

      select * from x where z=b

      I'll send that query back to Teiid using the Teiid connection in the CommandContext resulting in the translator getting two separate, but simulataneous query that are pushed to Cassandra.  Then, Teiid can work its magic to resolve the intersection.  While that's all a *bit* convoluted to work around the fact that Teiid doesn't allow a translator to declare a maximum number of AND clauses is supported (similar to setMaxDependentInPredicates), that's not my real issue...

       

      Experimenting with the planner, I discovered that

      select * from x

      intersect

      select * from x where y=a

      result in two queries pushed to translator when it should be easy to detect that the second is always going to be a subset of the first and, thus, only one query is necessary.

       

      Thoughts?