What is the fastest way to insert a huge array (10M elements) from a C # application?
So far I have used volumetric insertion. A C # application creates a large text file, and I load it with the BULK INSERT . Out of curiosity, I wrote a simple user defined CLR value function.
[SqlFunction(Name = "getArray", FillRowMethodName = "FillRow")] public static IEnumerable getArray(String name) { return my_arrays[name];
And this request:
INSERT INTO my_table SELECT data FROM dbo.getArray('x');
It works almost 2 times faster than the volume equivalent. Exact results:
BULK - 330 (write to disc + insert) TVF - 185s
Of course, this is due to write overhead, but I don't know if there is a BULK insert in the memory equivalent.
So my question is: is it better to bind TVF to BULK (which is created for huge inserts), or I donβt see something here. Is there any third alternative?
source share