I'm building a MySql query that batch inserts 4096 records at once. The actual insert is quite fast but the bottleneck is generating the query. Any hints on optimizing this? The string generation is currently taking about 18 times longer than the query.
let builder = StringBuilder(524288)
Printf.bprintf builder
"
INSERT INTO %s
(`ID`,
`Tag`,
`Port`,
`Excess`,
`Return`,
`StartDate`,
`EndDate`
)
values "
x.evaluationstable
evaluations
|> Seq.iter(fun (e) ->
Printf.bprintf builder
" (%d, '%s', '%s', %A, %A, %A, %A), "
e.ID
e.Tag
e.Port
e.Excess
e.Return
(e.StartDate.ToString(x.datetimeformat))
(e.EndDate.ToString(x.datetimeformat))
)