I am facing a performance issue while sending a list of values to SQL Server DB by a stored procedure.
When I passing a list as a type-table param
, the SQL Profiler shows me that the list execute as
INSERT INTO Entries (id, name) VALUES (@p1, @p2)
INSERT INTO Entries (id, name) VALUES (@p3, @p4)
INSERT INTO Entries (id, name) VALUES (@p5, @p6)
INSERT INTO Entries (id, name) VALUES (@p7, @p8)
INSERT INTO Entries (id, name) VALUES (@p9, @p10)
and I want to execute the list as(better performance)
INSERT INTO Entries (id, name) VALUES (@p1, @p2), (@p3, @p4), (@p5, @p6),(@p7, @p8),(@p9, @p10)
I tried to check the option with string_split for simple variables but it is not efficient for complex objects.
I also researched for solutions in Dapper and EF(still with SP) and both are still executing an insert loop on the list.
Any ideas?