You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The NormalizeTimeStamp method also calls `GetNativeType'.
At the moment, inserting 10,000 rows with 15 columns (four of them require calling NormalizeTimeStamp) via BulkCopyType.MultipleRows is about 3 times faster than BulkCopyType.ProviderSpecific. At the moment, BulkCopyType.ProviderSpecific cannot be used in production - it always works slower.
BulkCopyType.MultipleRows spends a lot of time and memory generating SQL strings, and BulkCopyType.ProviderSpecific spends 99% of the time calling GetNativeType 200,000 times.
As a good solution, you can calculate GetNativeType before loops, because it makes no sense to check the column type for each row.
The text was updated successfully, but these errors were encountered:
Good afternoon!
After switching to .NET 8 bugs have been fixed in the
ProviderSpecificCopySyncImpl
method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/DataProvider/PostgreSQL/PostgreSQLBulkCopy.cs#L139Bugs have been fixed by adding lines:
https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/DataProvider/PostgreSQL/PostgreSQLBulkCopy.cs#L167
https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/DataProvider/PostgreSQL/PostgreSQLBulkCopy.cs#L170
Both lines use the
GetNativeType
method - this method is incredibly slow. And it is called in a loop for each column and for each row.In the line https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/DataProvider/PostgreSQL/PostgreSQLBulkCopy.cs#L170 you can swap the check order to reduce the number of GetNativeType calls:
if (value is DateTimeOffset dto && _provider.GetNativeType(dataType.DbType) == NpgsqlProviderAdapter.NpgsqlDbType.TimeTZ)
The
NormalizeTimeStamp
method also calls `GetNativeType'.At the moment, inserting 10,000 rows with 15 columns (four of them require calling
NormalizeTimeStamp
) viaBulkCopyType.MultipleRows
is about 3 times faster thanBulkCopyType.ProviderSpecific
. At the moment,BulkCopyType.ProviderSpecific
cannot be used in production - it always works slower.BulkCopyType.MultipleRows
spends a lot of time and memory generating SQL strings, andBulkCopyType.ProviderSpecific
spends 99% of the time callingGetNativeType
200,000 times.As a good solution, you can calculate
GetNativeType
before loops, because it makes no sense to check the column type for each row.The text was updated successfully, but these errors were encountered: