0

I use a stored procedure to fetch data and modifications from the database. If i use LINQ for the same job will there be any performance issue? I mean will I get better performance or not? I saw that LINQ syntax is bit complicated, so is there any tool which help me to generate LINQ syntax.

thanks

TheBoyan
  • 6,802
  • 3
  • 45
  • 61
Thomas
  • 33,544
  • 126
  • 357
  • 626
  • 1
    See the related questions: http://stackoverflow.com/questions/4044400/linq-performance-faq, http://stackoverflow.com/questions/1229838/linq-performance, http://stackoverflow.com/questions/3584059/linq-performance – ChrisF Mar 17 '11 at 13:11
  • 1
    Voted to close, subjective/argumentative. Needs more meat to the question rather than just "please discuss all the issue". – user7116 Mar 17 '11 at 13:33

3 Answers3

2

There is a slight performance impact against using Linq2Sql VS calling stored procedures; for one, the stored procedure can be compiled and stored so subsequent calls are quicker, and you have more control and options in T-SQL land VS having Linq2Sql generate the statements for you.

However, unless your site is getting heavy traffic, theres no reason not to use it if you are looking for an easy way to get your site set up.

Tejs
  • 40,736
  • 10
  • 68
  • 86
2

In general, LINQ will not beat the performance of a stored procedure. After all, Linq2Sql generates SQL and that will never be better than a well-written stored procedure.

Linq2sql, if not used properly, can harm performance. That is often caused by developers that do not understand the deferred loading principle and that can lead to a LOT of queries.

Where it WILL create performance issues is with bulk operations. This is an area where you do not want to use Linq2Sql but you need SqlBulkCopy or stored procedures.

Nevertheless, I use it a lot and am happy in general.

Pleun
  • 8,856
  • 2
  • 30
  • 50
2

LinqPad is a free program and can be a way to learn LINQ. It comes loaded with 500 examples.

Jaime Oro
  • 9,899
  • 8
  • 31
  • 39
  • 1
    while LinqPad indeed is a great way to learn Linq, it is not really relevant to the question, as it does not help with determining the perf pros/cons of Linq vs. stored procedures. – Franci Penov Mar 17 '11 at 18:40
  • 2
    That is not entirely true, the second part of the question addresses any tools that can help to generate LINQ syntax and LinqPad is one of those... – Pleun Mar 17 '11 at 23:14
  • @Franci As Pleun said I was asking the second part of the question. Anyway, I think it's not a great idea to ask two questions in the same post. – Jaime Oro Mar 19 '11 at 15:53