[Haskell-cafe] Haskell SQL backends: How is data handed over?
Olaf Klinke
olf at aatal-apotheke.de
Tue Aug 9 19:34:07 UTC 2022
Dear Café,
I was discussing with a friend the fastest way to shovel data into a
SQL database after parsing the raw (textual) data with Haskell. I am
concerned about numeric conversion: In my experience parsing the file
structure is fast. The majority of the time is spent converting strings
of digits to numbers. I hoped that once Haskell has constructed a
Double, the backend driver can hand that binary value over to the
database engine. But Database.HDBC.Statement has a field
orginalQuery :: String
and HDBC has functions
prepare :: Connection -> String -> IO Statement
run :: Connection -> String -> [SqlValue] -> IO Integer
which makes me wonder whether the backend constructs a complete SQL
query statement in form of a string (including the SqlValues), and
hands that to the database driver to parse. Is that indeed so?
If yes, the numbers should never be parsed in the first place: The DB
will do that anyways. I might as well construct a new CSV file and let
the database do a bulk insert on that. The above is specific to the
HDBC backend. If there are other backends/frameworks that do the
marshalling more efficiently, please let me know.
Thanks
Olaf
More information about the Haskell-Cafe
mailing list