[Haskell-cafe] Haskell SQL backends: How is data handed over?
ollie at ocharles.org.uk
Wed Aug 10 07:11:03 UTC 2022
I can't speak for SQL in general, but if you're targeting PostgreSQL note that the hasql library uses a binary wire format. You'll need to use parameterized queries to benefit from this, but it would let you avoid encoding digits to ASCII.
On Tue, 9 Aug 2022, at 8:34 PM, Olaf Klinke wrote:
> 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.
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe