                   (:max (first (jdbc/query pool (vector (format "select max(%s) as max from %s" id-col table))))))
         ranges (partition-all 2 1 (range n-min n-max (:sql/rows-per-segment task-map)))
         columns (or (:sql/columns task-map) [:*])]
-    (map (fn [[l h]]
-           {:low l
-            :high (dec (or h (inc n-max)))
-            :table (:sql/table task-map)
-            :id (:sql/id task-map)
-            :columns columns})
-         ranges)))
+    [(map (fn [[l h]]
+            {:low l
+             :high (dec (or h (inc n-max)))
+             :table (:sql/table task-map)
+             :id (:sql/id task-map)
+             :columns columns})
+          ranges)
+     {:sql/lower-bound n-min
+      :sql/upper-bound n-max}]))
+
 
 (defn update-partition [content acked]
   (dissoc content acked))

        step (bigint (/ (- n-max n-min) steps-num))
        ranges (partition-all 2 1 (range n-min n-max step))
        columns (or (:sql/columns task-map) [:*])]
    (map (fn [[l h]]
           {:low (util/bigint-to-bytes l)
            :high (util/bigint-to-bytes (dec (or h (inc n-max))))
            :table (:sql/table task-map)
            :id (:sql/id task-map)
            :columns columns})
         ranges)))

(defn partition-table [{:keys [onyx.core/task-map sql/pool] :as event}]
  (let [table (name (:sql/table task-map))

        checkpoint-ms (:checkpoint-ms pipeline)
        pending-messages (:pending-messages pipeline)
        pool (task->pool task-map)
        [partitions event-map] (table-partitioner (assoc event :sql/pool pool))
        content (:content pipeline)
        chunk (into {} 
                    (map (fn [p] [p :incomplete]) 
