[Haskell-cafe] Haskell SQL backends: How is data handed over?

Steven Shaw steven at steshaw.org
Wed Aug 10 09:50:08 UTC 2022


Hi Olaf,

It's unlikely that a HDBC database driver will reconstruct a String query
and execute that against the database. The originalQuery is simply the one
you originally provided to prepare the Statement. You probably want
Statement's
    execute :: [SqlValue] -> IO Integer
or
    executeMany :: [[SqlValue]] -> IO ()

The executeMany is intended to send a batch of prepared arguments to the
database driver. However, I did note that the PostgreSQL driver for HDBC
doesn't handle this efficiently. So, check the implementation for your
specific backend.


https://github.com/hdbc/hdbc-postgresql/blob/master/Database/HDBC/PostgreSQL/Statement.hsc#L207-L210

All that said, if you are doing a large bulk import, it could certainly be
more efficient to use your database's facilities for doing bulk import. e.g.
https://www.postgresql.org/docs/current/sql-copy.html

You might also find that you are better off using an alternative to HDBC
for your specific dbms, depending on the performance you require and
whether executeMany is implemented efficiently in the HDBC driver for your
dbms.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20220810/ce1ef005/attachment.html>


More information about the Haskell-Cafe mailing list