Speedup final view insert with analyse Sometimes (when track_counts=off maybe?) the query planner takes the wrong approach when selecting data for the "bag" table and the statement takes many hours to finish instead of minutes.
1 files changed, 8 insertions(+), 1 deletions(-) M src/straatnaam/lvbag.clj
M src/straatnaam/lvbag.clj => src/straatnaam/lvbag.clj +8 -1
@@ 304,7 304,14 @@ (defn- insert-bag! [db sn] (log/debug "inserting bag data for" sn) (sql/db-do-commands db true [(str "SET SCHEMA '" sn "'") [;; Force running analyze to help query planner ;; in the next insert step, otherwise it may ;; take a very long time. (str "ANALYSE " (->> template-tables (map #(str sn "." %)) (string/join ", "))) (str "SET SCHEMA '" sn "'") (str "INSERT INTO bag " ;; Keeping the query in the source code ;; because putting it in the template