472,958 Members | 2,543 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

LINQ To SQL

Why is it so slow? I really like
that queries but using DataReader
i have done my task's much more faster
than ising LINQ...
Jul 25 '08 #1
4 1940
Define slow? It depends on what your queries are, and whether you have
caused it to do multiple round-trips (for sub-data) rather than
loading data early, and whether you've filtered things at the right
point [in the composable query, rather than downstream]. In general,
the (fixed) network IO vastly outweighs any client implementation
details like LINQ, but you might need to be more specific to get a
sensible answer...

Marc
Jul 25 '08 #2
LINQ does 10-15 other steps before generating the actual query, which makes
LINQ slow. But it might be good if you have a multi processor system, because
LINQ is degined to take multi processor to make the things fast.

regards,
Pankaj
http:\\a2zdotnet.com

"Jacek Jurkowski" wrote:
Why is it so slow? I really like
that queries but using DataReader
i have done my task's much more faster
than ising LINQ...
Jul 25 '08 #3
LINQ does 10-15 other steps before generating the actual query, which makes
LINQ slow.
Care to be more specific? What steps are you referring to? Note that
you can use a few tricks to speed things up; for example (I haven't
used it myself) compiled queries:
http://msdn.microsoft.com/en-us/libr...qtosql_topic14

You might also wish to disable object tracking if you don't need it,
and write your query (or use load options) such that any sub-data you
need is retrieved in the first query rather than lazily. Again, you
really need to give some indication of what you are seeing as "slow"
to disuss them sensibly. You say there are 10-15 other steps: which of
them, exactly, is offending you?
But it might be good if you have a multi processor system, because
LINQ is degined to take multi processor to make the things fast.
I'm not aware of LINQ-to-SQL doing anything so exotic; you may be
thinking of "Parallel Extensions"

Marc
Jul 25 '08 #4
Jacek Jurkowski wrote:
Why is it so slow? I really like
that queries but using DataReader
i have done my task's much more faster
than ising LINQ...
Read this series and you might start thinking otherwise:
http://blogs.msdn.com/ricom/archive/...ce-part-1.aspx

There's a cost, obviously, and you will never get faster than using a raw
DataReader, but the performance overhead can be brought down considerably.
Did you use CompiledQuery and time multiple executions?

If the problem is not in the reflection and code generation of LINQ, you may
want to have a look at what SQL output you're actually generating. It may
not be optimal for a variety of reasons. LINQ abstracts considerably over
queries so you don't have to, but it's not perfect, and it can especially
break down if you mix in other constructs with LINQ to Objects. You can use
a tool like LINQPad (http://www.linqpad.net/) to see what your LINQ queries
are actually compiling to.

Finally, the ease of use of LINQ mean that it'll help you speed up
development even if you don't use LINQ to generate the actual queries. LINQ
works just as well with stored procedures, so if you have a particularly
tough query that needs careful optimization, you can stick it in a sproc and
use a few lines of declarative code (or a drag and drop from the Server
Explorer) to get a strongly-typed method for it.

--
J.
Jul 25 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dave Johnson | last post by:
Greetings, i want to be able to use linq new technology with sql server. the senario i am not able to do so far is as follow: 1- i program with linq 2- be able to generate and manipulate...
4
by: cj | last post by:
Can I use LINQ in VB .Net 2008 to get to a Visual FoxPro Table? I've seen demos of it with SQL Server but they've used it with a server browser and I don't think that'd work when I need to see VFP...
9
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
Hi all: after reading different places/sites about linq... I ran into these questions: 1. What framework do we need to run linq ? (does it depend on what version of visual studio we have?) how...
0
by: =?Utf-8?B?SHlwZXJjb2Rlcg==?= | last post by:
I'm encountering some strange behavior after deploying a ASP.net 3.5 website to production, i'm unable to reproduce these in my dev environment. This error seems to occur very randomly but it's...
4
by: =?Utf-8?B?RXJpYyBGYWxza2Vu?= | last post by:
We’re storing our main entity in an insert only table which stores the history of past revisions, but we’re facing problems with storing this history as LINQ will only update the entity, and...
14
by: thj | last post by:
Hi, I was wondering what you guys are using and why? LINQ to SQL or NHibernate? Thanks in advance, Tommy
9
by: Cirene | last post by:
I'm about to begin a brand new, big, ASP.NET project (using 3.5 .net fw), VS 2008. I'm using MySQL as the backend (customer request.) I have absolutely no experience with LINQ and/or the Entity...
3
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm receiving a "Specified cast is not valid" error that has something to do w/ the keys involved. The stack trace is: ...
4
by: George | last post by:
I am a bit conservative type and usually give some time for technology to mature before starting to try it. Today my question is Linq. To start using it or not. So here is the voting questions....
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.