 
 (defn- where-plans [db where order]
   [{:action  :db-scan
-    :options nil
-    :source  nil
     :order   [:id :asc]
     :size    :db
     :cost    [:scan :db]}])

    source
    {:action  :filter
     :options {:where where}
     :source  source
     :order   (:order source)
     :size    (:size source)
     :cost    [:scan (:size source)]}))

(defn- order-plan [source order]
  (if (or (not order) (= order (:order source)))
    source
    {:action  :sort
     :options {:order order}
     :source  source
     :order   order
     :size    (:size source)
     :cost    [:sort (:size source)]}))

(defn- offset-plan [source offset]
  (if-not offset
    source
    {:action  :offset
     :options {:offset offset}
     :source  source
     :order   (:order source)
     :size    (:size source)
     :cost    [:scan :range]}))

(defn- limit-plan [source limit]
  (if-not limit
    source
    {:action  :limit
     :options {:limit limit}
     :source  source
     :order   (:order source)
     :size    (:size source)
     :cost    [:scan :range]}))

(defn- only-plan [source only]
  (if-not only
    source
    {:action  :only
     :options {:only only}
     :source  source
     :order   (:order source)
     :size    (:size source)
     :cost    [:scan (:size source)]}))

(defn symbolic-costs [{:keys [source] :as plan}]
  (cons (:cost plan)

   :insert        q-insert
   :update        q-update
   :delete        q-delete
   :explain       q-explain
   :create-index  q-create-index
   :drop-index    q-drop-index
   :list-indexes  q-list-indexes
