IssueRaiser

Reading large data (binary, text) asynchronously is extremely slow

Reading a 10MB `VARBINARY(MAX)` value asynchronously takes around 5 seconds my machine, while doing the same synchronously takes around 20ms. Increasing the data size to 20MB increases the running time to around 52 seconds. These numbers were with Microsoft.Data.SqlClient 1.1.3, but 2.0.0-preview4.20142.4 has the same issue (it actually seems slightly slower). Note that I'm not posting final BDN results because the benchmark ran extremely slowly. Note that this looks very similar to #245, but that issue was fixed for 1.1.0. The difference may be that here we're writing binary data - or possibly the bigger size. <details> <summary>Benchmark code</summary> ```c# [MemoryDiagnoser] public class Benchmarks { const string ConnectionString = "Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0"; [GlobalSetup] public void Setup() { using var conn = new SqlConnection(ConnectionString); conn.Open(); using var cmd = conn.CreateCommand(); cmd.CommandText = @" IF OBJECT_ID('dbo.data', 'U') IS NOT NULL DROP TABLE data; CREATE TABLE data (id INT, foo VARBINARY(MAX)) "; cmd.ExecuteNonQuery(); cmd.CommandText = "INSERT INTO data (id, foo) VALUES (@id, @foo)"; cmd.Parameters.AddWithValue("id", 1); cmd.Parameters.AddWithValue("foo", new byte[1024 * 1024 * 10]); cmd.ExecuteNonQuery(); } [Benchmark] public async ValueTask<int> Async() {

Posted by roji on Jun 5, 2020, 2:59 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments

onboarding (Sysadmin)

Reading large data (binary, text) asynchronously is extremely slow

rojiJun 5, 2020, 2:59 PM

Reading a 10MB `VARBINARY(MAX)` value asynchronously takes around 5 seconds my machine, while doing the same synchronously takes around 20ms. Increasing the data size to 20MB increases the running time to around 52 seconds. These numbers were with Microsoft.Data.SqlClient 1.1.3, but 2.0.0-preview4.20142.4 has the same issue (it actually seems slightly slower). Note that I'm not posting final BDN results because the benchmark ran extremely slowly. Note that this looks very similar to #245, but that issue was fixed for 1.1.0. The difference may be that here we're writing binary data - or possibly the bigger size. <details> <summary>Benchmark code</summary> ```c# [MemoryDiagnoser] public class Benchmarks { const string ConnectionString = "Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0"; [GlobalSetup] public void Setup() { using var conn = new SqlConnection(ConnectionString); conn.Open(); using var cmd = conn.CreateCommand(); cmd.CommandText = @" IF OBJECT_ID('dbo.data', 'U') IS NOT NULL DROP TABLE data; CREATE TABLE data (id INT, foo VARBINARY(MAX)) "; cmd.ExecuteNonQuery(); cmd.CommandText = "INSERT INTO data (id, foo) VALUES (@id, @foo)"; cmd.Parameters.AddWithValue("id", 1); cmd.Parameters.AddWithValue("foo", new byte[1024 * 1024 * 10]); cmd.ExecuteNonQuery(); } [Benchmark] public async ValueTask<int> Async() {

Comments (0)

No comments yet. Start the discussion.

Comment on this issue