Recently, we identified that one of our poor performing page was due to the difference in ARITHABORT option setting between SQL Server Instance and SQL Client (i.e., ADO.NET). We could resolve this issue by executing a following command as soon as SQLConnection gets opened -
SqlCommand comm = new SqlCommand("SET ARITHABORT ON", objSqlConn);
comm.ExecuteNonQuery();
There are many articles over the internet which says when the query takes long to execute from application, but executes quickly in SSMS then it is most probably the issue of poor indexing, parameter sniffing or ARTHABORT option difference. In my case, it was the third one which I could reconfirm by checking the query execution plan as well.
Though the issue is resolved, I am curious to know why I need to run this command explicitly in order to make the query performance in sync with SQL server.
Also, if it is a known thing since years, then Microsoft must have thought about setting this option to ON by default for SqlConnection. After all, SQL Server and .NET client are their own products.
Any idea of how to make SET ARITHABORT ON by default while executing queries using ADO.NET?