From b0329b05dce255fa719b04dd91ded8b0e0e5a1b4 Mon Sep 17 00:00:00 2001 From: Felipe Lessa Date: Thu, 6 Sep 2012 14:18:42 -0300 Subject: [PATCH] Use a bigger default chunk size when constructing the query. The default is 112 bytes, or 56 characters. With this commit we start using 992 bytes, or 496 characters, which should be enough to fit most queries without needing reallocations or memory copies. --- src/Database/Esqueleto/Internal/Sql.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Database/Esqueleto/Internal/Sql.hs b/src/Database/Esqueleto/Internal/Sql.hs index fcbefdd..56c3244 100644 --- a/src/Database/Esqueleto/Internal/Sql.hs +++ b/src/Database/Esqueleto/Internal/Sql.hs @@ -339,7 +339,7 @@ rawSelectSource mode query = src run conn = uncurry withStmt $ - first (TL.toStrict . TLB.toLazyText) $ + first builderToText $ toRawSql mode (fromDBName conn) query massage = do @@ -451,7 +451,7 @@ rawExecute :: ( MonadLogger m rawExecute mode query = do conn <- SqlPersist R.ask uncurry execute $ - first (TL.toStrict . TLB.toLazyText) $ + first builderToText $ toRawSql mode (fromDBName conn) query @@ -508,6 +508,12 @@ update = rawExecute UPDATE . from ---------------------------------------------------------------------- +builderToText :: TLB.Builder -> T.Text +builderToText = TL.toStrict . TLB.toLazyTextWith defaultChunkSize + where + defaultChunkSize = 1024 - 32 + + -- | (Internal) Pretty prints a 'SqlQuery' into a SQL query. -- -- Note: if you're curious about the SQL query being generated by