Sam
Sam

Reputation: 30388

Is there a performance difference SQL vs LINQ

We're building an application with DocumentDb backend that will get lots of hits and its reponsiveness is absolutely paramount.

I wanted to see if there was a "preferred" approach from a performance stand point in querying DocumentDb. Should we use SQL for our queries or LINQ?

Upvotes: 1

Views: 919

Answers (1)

Andrew Liu
Andrew Liu

Reputation: 8119

Theoretically, there shouldn't be a noticable difference in regards to responsiveness.

LINQ is a simply a fluent wrapper API, that which given a LINQ expression generates a SQL expression. You can view the generated SQL expression by applying toString() to the end of the LINQ expression. The performance hit on converting a LINQ expression to SQL is negligible compared the time it takes to perform I/O.

In practice, the translation from a LINQ expression may result in a sub-optimal SQL expression when dealing with corner cases. For those corner cases, working directly with SQL would be preferred.

Upvotes: 2

Related Questions