|
1254 | 1254 | {:id (generated-key db 3) :name "Orange" :appearance "round" :cost nil :grade nil} |
1255 | 1255 | {:id (generated-key db 2) :name "Pear" :appearance "yellow" :cost nil :grade nil}] rows))))) |
1256 | 1256 |
|
| 1257 | +(comment |
| 1258 | + (def ones (repeat 100 1)) |
| 1259 | + (def select-1 (str "select " (str/join ", " ones))) |
| 1260 | + (def select-? (into [(str "select " (str/join ", " (map (fn [_] "?") ones)))] ones)) |
| 1261 | + (time (jdbc/execute-one! (-> a :database :pooled-db :datasource) [select-1])) |
| 1262 | + (time (jdbc/execute-one! (-> a :database :pooled-db :datasource) select-?)) |
| 1263 | + (require '[clojure.java.jdbc :as j]) |
| 1264 | + (time (j/query (-> a :database :pooled-db) [select-1])) |
| 1265 | + (time (j/query (-> a :database :pooled-db) select-?))) |
| 1266 | + |
| 1267 | +(deftest check-prepared-performance |
| 1268 | + (let [ones (repeat 100 1) |
| 1269 | + select-1 [(str "select " (str/join ", " ones))] |
| 1270 | + select-? (into [(str "select " |
| 1271 | + (str/join ", " (map (fn [_] "?") ones)))] |
| 1272 | + ones)] |
| 1273 | + (println "\nSanity check on prepared statement parameter performance.") |
| 1274 | + (doseq [db (test-specs) |
| 1275 | + :when (not (or (derby? db) (hsqldb? db)))] |
| 1276 | + (println " " db) |
| 1277 | + (time (dotimes [n 100] (sql/query db select-1))) |
| 1278 | + (time (dotimes [n 100] (sql/query db select-?))) |
| 1279 | + (sql/with-db-connection [con db] |
| 1280 | + (time (dotimes [n 100] (sql/query con select-1))) |
| 1281 | + (time (dotimes [n 100] (sql/query con select-?))))))) |
| 1282 | + |
1257 | 1283 | (deftest test-create-table-ddl |
1258 | 1284 | (is (re-find #"`foo` int default 0" |
1259 | 1285 | (sql/create-table-ddl :table |
|
0 commit comments