Uploaded image for project: 'java.jdbc'
  1. JDBC-174

PostgreSQL/MySQL need extra options to do insert-multi! with columns as a single operation

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Completed
    • Labels:
      None

      Description

      java.jdbc uses a single prepared statement invocation for insert-multi! (columns) and provides each param group as a batch. By default, both PostgreSQL and MySQL run this as multiple statements, one for each batch of parameters (which is counter-intuitive, certainly as far as the JDBC docs are concerned).

      However, you can provide options in your db-spec map to address this: PostgreSQL requires :reWriteBatchedInserts true and My SQL requires :rewriteBatchedStatement true (both non-standard JDBC options, of course!). This should cause the drivers to rewrite the SQL to a single insert with repeated values groups, and then it will do a single insert as "expected".

      At a minimum, update the docstring for insert-multi! and the clojure-doc documentation.

      But also consider actually producing that style of multiple insert SQL for databases known to support it (not all of them do). Perhaps introduce a new option on insert-multi! itself?

        Attachments

          Activity

            People

            • Assignee:
              seancorfield Sean Corfield
              Reporter:
              seancorfield Sean Corfield
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: