            :ordered (:ordered main-plan)
            :source  main-plan})
 
+      ; meh -> fair but not great
       (= :or op)
         (let [sub-plans (map #(where-plan db % order) wrest)]
           {:action  :union

               :ordered ordered})
            (root-filter-plan db where order)))

      (= :and op)
        (let [main-plan     (where-plan db (first wrest) order)
              filter-wheres (next wrest)]

(defn- where-plan [db where order]
  (let [[op & wrest] where]
    (cond
      ; only choice -> optimal
      (not op)
        (root-plan db order)

      ; only simple choice -> probably optimal
      (= :!= op)
        (root-filter-plan db where order)

      ; when no index, use root-filter-plan -> optimal
      ; when reasonable index and no order -> probably optimal
      ; when reasonable index and order -> may be suboptimal, but reasonable
      (= := op)
        (let [[attr aval] wrest]
          (if (index-on db attr)
