Skip to content

Drastic performance difference between using SqlClient and SSMS #412

@Skyppid

Description

@Skyppid

We're currently saving a complex object structure in XML form. For safety and convenience we're using an SQL Express Server for handling the data. Right now we save the full document once every time changed (biggest being around 28MB of size) which should be no problem for SQL Server to handle.

The data is stored in a table with "Id (int, PK, Identity), Revision (int), Timestamp (datetime2), Data (xml)".
When I run the following query on SSMS (with Execution Plan), I see that it runs a clustered index seek which obviously doesn't take long for a table with ~600 rows. Using the SQL profiler I get the full XML data (non-trimmed) in 184ms (CPU: 47, Reads: 27044).

Now I do the very same thing in my application using plain SqlClient connection with the very same query: 36923ms (CPU: 47, Reads: 18286)

It's the exact same query when I look at the Profiler. Yet it takes ages longer until the query completes. And after that it also takes quite a while until ReadAsync() returns back with the XML data.

Can anybody explain to me why this happens? We currently have load times up to 6 minutes where as ~2.5 minutes are just retrieving the latest data from SQL Server.

As for the connection: The server is only running with TCP/IP protocols enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Performance 📈Issues that are targeted to performance improvements.

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions