 (defn- q-explain [db {[query-type opts] :query :as explain-opts}]
   (assert (= query-type :select))
   (let [{:keys [where order offset limit only]} opts]
-    (select-plan db where order offset limit only)))
+    (find-plan db where order offset limit only)))
 
 (defn- q-create-index [db {:keys [on where]}]
   (assert (not (on (:imap db))))


(defn- q-update [db {:keys [with] :as opts}]
  (assert with)
    (db-apply db (q-select db opts)
      (fn [[int-rmap int-imap] old-record]
        (let [new-record (merge-compact old-record with)]
          [(rmap-update int-rmap old-record new-record)
           (imap-update int-imap old-record new-record)]))))

(defn- q-delete [db opts]
  (db-apply db (q-select db opts)
    (fn [[int-rmap int-imap] old-record]
      [(rmap-delete int-rmap old-record)
       (imap-delete int-imap old-record)])))

        o-plans (map #(order-plan % order) w-plans)]
    (least-by quantify-cost o-plans)))

(defn- find-plan [db where order offset limit only]
  (-> (wo-plan db where order)
    (offset-plan offset)
    (limit-plan limit)
