|
You do you understand the meaning of the word "can" right? You are arguing assertions I never made nor even discussed.
To turn this around, are you honestly asserting that stored procedures have zero CPU cost? Moreover, have you seen what some developers put in stored procedures?
jschell wrote:
I am guessing they had "benchmarks" to "prove" it.
No, actual tests with actual databases with terabytes of data which could get under extremely heavy loads due to tens of thousands of clients. Offloading some of the processing to clients helped immensely.
|
|
|
|
|
Joe Woodbury wrote: You do you understand the meaning of the word "can" right?
However you also said "anything more than simple stored procedures were prohibited for this reason"
Joe Woodbury wrote: To turn this around, are you honestly asserting that stored procedures have zero
CPU cost?
Nope. But there is a big leap from there to banning everything.
Joe Woodbury wrote: Moreover, have you seen what some developers put in stored procedures?
And that has what to do with anything? I have seen a C++ class with 200,000 lines of code. I have seen an application that dragged the ENTIRE database across the network, computed on it, and then sent it back and that specific design was a bottleneck. I have seen a VP lock up a entire database and idle 200 call center employees on a weekly basis because he insisted on having direct access to the production database.
All of those however are PROCESS PROBLEMS. They have nothing to do with technology.
Joe Woodbury wrote: actual tests with actual databases with terabytes of data which could get under
extremely heavy loads due to tens of thousands of clients
Which seems like something that qualify the initial post with would have made it much clearer. Most businesses will never see anything like that however.
Joe Woodbury wrote: Offloading some of the processing to clients helped immensely.
One might suppose however that other businesses have other business needs and thus restrictions to one business environment should not be blindly applied to all industries and all businesses.
|
|
|
|
|
jschell wrote: However you also said "anything more than simple stored procedures were prohibited for this reason"
Do you understand the concept of an illustration to make a point? To anyone with the slightest literacy, this was clearly an illustration of why stored procedures CAN be bad. Now, I could understand you misreading one comment, but you continue to argue against assertions I never made and even make statements that support what I wrote, but in condescending way. Despite all this, you never refuted my actual points. Based on this and previous posts by you, I can't help but wonder if you are being intentionally antagonistic and argumentative.
I don't know how old you are or how experienced in the field of computer science, but you come off as very arrogant and immature. When your errors are pointed out, you become combative and change your arguments as well as turning them back on the original poster as though it was all their fault. This borders on narcissism and makes dealing with you very unpleasant.
|
|
|
|
|
Joe Woodbury wrote: Do you understand the concept of an illustration to make a point?
Your original comment did not seem like an example of one case where it could be a problem. It is that comment to which I responded of course.
The statements, taken together, seemed to suggest strongly that in most cases stored procedures should be avoided.
Joe Woodbury wrote: Despite all this, you never refuted my actual points.
I didn't need to because you provide further qualification in follow on posts that made it clear (presumably) that you were referring to a very limited problem domain space.
That however doesn't alter the fact that your original comment did not make that clear.
Joe Woodbury wrote: When your errors are pointed out,
Your original comment was made without qualification. I disputed the totality of that statement. Best I can tell you are now agreeing that your original comment only applies to a limited domain.
I don't see an error in my part in terms of your lack of the original qualification.
But I can assure you that I am more than willing to accept when I am in error - when in fact that is the case. Versus of course someone just repeatedly claiming that that is the case.
Joe Woodbury wrote: ...and makes dealing with you very unpleasant.
Best I can suggest for that is that you park the emotionalism at the door.
|
|
|
|
|
Wasn't LINQ to SQL Dead on Arrival?
modified 20-Oct-19 21:02pm.
|
|
|
|
|
I remember them releasing competing db platforms at the same time. LINQ to SQL, LINQ to Entities, Entity Framwork, Apparition Architect, yada, yada.
That's one of the reasons I stayed away initially. I thought it was the height of stupidity. In other words, coming from MS, I didn't give it a second thought.
|
|
|
|
|
Ok, so here a link to a discussion by people who did use it in production:
LINQ Discussion[^]
"with my experience with EF and Linq,
If you are developing an application for less than 10-20 users and not expecting any huge data, go with EF and LINQ
Otherwise,
Never ever use LINQ and EF. I never saw many developers who care about performance during development. So don't adopt architecture that cost you more in the long run.
"
modified 20-Oct-19 21:02pm.
|
|
|
|
|
I would go with Entity Framework + Stored Procedure. With EF the advantage that we can get is the OR Mapping.
Now the question goes to you, If you want to take advantage of the technology to simplify or make it better then go with EF Designer or Code first approach and also if you want to do some code re-factoring and wish to use your existing store procedure, Yes you can do so.
Some interesting articles
http://msdn.microsoft.com/en-us/data/gg699321.aspx[^]
http://www.dotnetcurry.com/ShowArticle.aspx?ID=938[^]
Thanks,
Ranjan.D
|
|
|
|
|
Don't mean to be dense, but I'm not really following the advantages here.
What benefit do I gain by moving queries out of stored procedures and into compiled code?
|
|
|
|
|
Quote: What benefit do I gain by moving queries out of stored procedures and into compiled code?
I see two different set of peoples arguing about the Usage , Performance, Benefits of Stored Procedures , it's maintainability etc. I'm fine with either way.
I don't know how you really want to go with, I say it depends on how we are deciding to go with. That's the reason I said , The Entity Framework doesn't really restricts the usage of Stored Procs , You can still make a call but what you get with EF is the result set as object. Is it good
I think if you are planning to move out the queries out of Stored Proc, you will end up in writing tons on code, though it's compiled I don't think there would be a great benefit. Some times you might even end up with performance issues.
I have seen several hundreds to thousands lines of stored procedures, If some one tells me to move them out of it to EF compiled queries , I would question why I'm doing this ?
If you are working on some new products and wish to tryout EF with mix and match SP's it's good. But I don't think it's a good idea to perform code re-factoring for the existing ones.
Thanks,
Ranjan.D
|
|
|
|
|
Actually, I'm starting a couple of new projects, but I don't see trying it out unless there are distinct and tangible benefits. Looks like it would be cool for non database stuff, but for a relational db, I'm not hearing anything it does for me that I don't get out of stored procs.
|
|
|
|
|
It's the principle of keeping the code in one place, as opposed to keeping it in the right place.
Be excellent to each other. And... PARTY ON, DUDES!
Abraham Lincoln
|
|
|
|
|
Well said.
|
|
|
|
|
Following is my comparision between Entity Framework (ORM that uses LINQ) and Stored Procedures.
Stored Procedure Pros: Much faster performance over EF/LINQ, Could be updated without recompiling the code based since it's in the database, better separation of logic, you could utilize your DBAs, Works even if the database structure / design is poor, Much better security.
Cons: Slow development process, unnecessary / repeated coding, No flexibility - works on only one database (I mean someday your management/client wants to move to MySQL from SQL Server, you will have to rewrite everything). Need extensive knowledge of database (I mean just knowing front-end language doesn't work). Maintain two separate things. Unit Testing nightmare.
Entity Framework Pros: Crazy fast development time (you could skip one or two phases), Querying is very easy, Works even if you know only Front-End language, Flexible - you can change underlying database without changing your code base, Start coding without planning everything in advanced (for SP you need to create it first before you do anything), Only one code base to maintain, Code-First migrations makes seamless database changes (Just rebuilt the solution and push it, Magic!), If you need performance boost at particular scenario you can still use stored procedure and call it as a method.
Cons: Requires almost perfect database structure/design (all the primary keys, foreign keys, constraints, normalized tables etc.), performance is not as good as SP (but you can use SP in that case, or buy a better hardware, or implement caching), your DBAs are now idle, Security is not as good as SP (Mostly any developer can do anything, in case of SP you could restrict the access of the SP and Tables to certain users), every minor changes in database call requires complete recompilation of code base.
Also once you know LINQ, you can use it against XML, CSV and many other data structures.
I have used EF in our latest product and it works great, few places where the performance was affected due to recursive call to methods, I changed it to stored procedures and now it's fine. I really like the abstraction and flexibility ORM offers. And now I only occasionally open SQL Server Management Studio, one less window to worry about.
|
|
|
|
|
Thanks for the in depth thoughts, man.
Rutvik Dave wrote: Also once you know LINQ, you can use it against XML, CSV and many other data
structures.
That seems like one of the best uses for it.
|
|
|
|
|
Christopher Duncan wrote: Why on earth would I want to move my queries into C# code?
No idea.
After all why would anyone want a database layer in their application when it would obviously make more sense to scatter it throughout the business layer in exactly each spot where it is used?
Christopher Duncan wrote: What am I missing?
Being a bit sarcastic lets suppose that you are less than a DB guru when it comes to your database. And no one else is either. And something is wrong with your database. You don't even know what.
So you hire a DB guru. And they fix it.
If you managed a reasonable business interface with your store procs you will have no or minimal changes to your application code. Without you will be refactoring everything.
modified 18-Oct-13 19:06pm.
|
|
|
|
|
jschell wrote: After all why would anyone want a database layer in their application
You're making the assumption that I was stipulating a 2 tier app. As I told Marc, even if you have a db layer, ultimatey you either write your queries in a compiled language or you put them in sql procs in your db. I'm not seeing the benefit of the former.
jschell wrote: Being a bit sarcastic lets suppose that you are less than a DB guru when it comes to your database. And no one else is either. And something is wrong with your database. You don't even know what.
Well, since you're invoking sarcasm, I'd say that if your team is that inept, perhaps you should all just step away from the keyboard. Perhaps a career change might even be in order.
Seriously, though, incompetence is not a reason to choose an architecture, although tool manufacturers make good money trying to make programming easy for those who should never be attempting it in the first place.
As for refactoring, if you make major changes to your database schema, you will absolutely be refactoring your code, whether it's LINQ or ADO. It's simply a matter of where - inside or outside of your business objects. Perhaps both. And as an aside, you don't need LINQ to create a collection of absracted business objects. We've been doing that since the days of DOS / C++.
|
|
|
|
|
Christopher Duncan wrote: You're making the assumption that I was stipulating a 2 tier app
No I wasn't. When I said "layer" I meant it in many ways but specifically that one would keep their database code in one location rather than scattering it throughout the rest of the application. The reason one does that is to make maintenance easier when changes to the database code is needed. And the same thing can be applied to using store procs in that they provide a disconnected api in the database.
Christopher Duncan wrote: Well, since you're invoking sarcasm
Unfortunately I said that incorrectly - the first part of my response was intended to be sarcastic where the second half wasn't.
Christopher Duncan wrote: I'd say that if your team is that inept,
There is of course a difference between "team" and "individual". Allowing all team members to hack at the database without review is probably a process failure, and one that I have seen in a company where performance and big data was a requirement. That would be a 'team' failure. An individual might also fail as well.
And unless one is specifically focused on a database it might still be the case that pulling in a consultant, with specific database experience, can be helpful in any company that does do large amounts of data.
Christopher Duncan wrote: As for refactoring, if you make major changes to your database schema
Probably but, as I believe I mentioned, with layering it is less likely that the entire code base needs to be changed versus just parts. And one might still be fairly competent at creating the interface API design while still failing at a database side solution that meets performance goals. So procs could provide that disconnect.
Christopher Duncan wrote: And as an aside, you don't need LINQ to create a collection of absracted
business objects. We've been doing that since the days of DOS / C++.
With about 20 years of experience specifically related to creating services and implementing persistent storage solutions in a variety of languages and database solutions I am aware of what they do.
|
|
|
|
|
I think we agree more than we disagree about this stuff. One of the scenarios someone brought up for doing queries in the code was the scenario where you work at a big enough company to have DBAs, procedures and politics, all of which would slow you down (nobody cares that you couldn't meet the deadline because the DBAs were stonewalling - you take the hit anyway). In that case, a reality check says you do what you gotta do.
And I didn't really take the sarcasm seriously. I figured you were just yanking my chain a bit, so I thought I'd yank back.
|
|
|
|
|
I have not and never intend to use linq to the database but then new and shiny does not attract me. Linq against iEnumerable is just excellent.
EF is a nightmare for new devs, sure it is easy and very quick developing the app but they have no depth in their knowledge of the database. Take a look at some of the questions in Q&A, they have no idea how a database works.
I hate black box software, if it breaks (and it does) you are screwed. EF being in it's 4th or 5th version is much more stable but is still a black box.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yeah, I've been reading an MVC book today and Linq against IEnumerable sounds extremely handy.
|
|
|
|
|
They're not mutually exclusive. I use neither. Old tried-and-true still rules.
Christopher Duncan wrote: SQL stuff in the database
The database is for data; code belongs in a code base (preferably a library).
Christopher Duncan wrote: move my queries into C# code
Because they're not there yet, but should be? And stored procedures still leave SQL in the program anyway in the form of the EXECUTE statements and parameters, etc.
Christopher Duncan wrote: I can make changes all day long in Sql Server and never touch web apps or
services
That's a baaaaad thing. Your code relies on the procedures doing a particular thing, but the procedure could be changed to do something completely different.
Or a table could be changed in a way that breaks the procedure.
And besides you'd still have to update the EXECUTE statements if you add or remove parameters.
Christopher Duncan wrote: If my db logic is in the code, I have to recompile and deploy the binaries every
time I touch something
Exactly; that's a gooood thing.
Christopher Duncan wrote: I know it's the shiny new thing to play with but other than resume enhancement,
I just don't see what value it brings to the table
That's about right. There's a guy on my team now who seems to think that every new thing is the bestest way to do things and any (me) who want to stick with tried-and-true need to be enlightened.
|
|
|
|
|
I know what you mean by tried-and-true. To a degree, that's what I've been invoking. Developing web apps with the sql code in the database and the procedural code in the app is the way things have been done for a long time, and it still works just fine.
That said, I try to keep an open mind as new technologies come out so I don't miss anything worthwhile. Of course, I've also been in the biz long enough to know that every time you turn around MS is telling you to throw away what you used to do in favor of this new, shiny thing - which they'll in turn tell you to throw away next year. Consequently, I take all this stuff with a grain of salt.
|
|
|
|
|
While I would say you're not missing anything, my experience is that people who write SP's have really no good practices regarding re-use (I believe another person responded about the lack of re-use with SP's as well.) And the triggers can get huge, spaghetti code, and invariably have undocumented logic and special case handlers, often using hardcoded data values. It's a mess, and when you talk to the people managing the code, they invariably say, we know it's a mess but we've had to make all these patches without any budget to fix the real underlying problems. And why's that? Because that would require changes to application, and the app devs, that were outsourced to write the app to begin with, are no longer around and nobody knows how to make changes in THAT code base without breaking half a dozen other features. So, that describes my real-world experiences, and probably those of many other people.
Also (stepping down from my rant platform), what you're describing in both cases is a 2-tier environment in most cases: app talking directly to the database. I hope I never have to work in a 2-tier environment ever again, but most people don't understand the benefits of a 3-tier environment. First off, you can isolate the application from "the database business." The stuff that manipulates data in the database's representation (aka schema) rather than the application's model, which can be quite different (but I'm not saying anything you don't already know.) But, what I like to do is then choose whether something should be an SP, or the SQL can be auto-generated by the middle tier, or it pulls in additional metadata that supplements the DB schema for further automation, or, as a last resort, the code in the middle tier does some processing of the data in C# (or whatever.)
But it's hard to convince people to take the time to architect a 3-tier system in which most stuff can be handled by metadata (schema + domain-specific declarative stuff) and then leverage either the middle tier or the SP's for the stuff that doesn't fit.
So, the question, in my mind, isn't "what am I missing with SP's vs Linq vs EF?", but "why am I still stuck in a 2-tier development environment?"
Well, that's my somewhat ranty reply.
Marc
|
|
|
|
|
I'm totally with you conceptually, although the rather loose way I phrased things allowed you to make an incorrect assumption.
It doesn't matter if you have 2 tiers or 42 - ultimately, you have to talk to the database. When you do, you can write your queries in compiled code, be it a separate assembly, a web service, etc. or you can write them in stored procedures.
My point is that I don't see the benefit in writing queries in a compiled, procedural language as opposed to letting sql be sql and do what you pay it to do.
On the other hand, it sounds like using LING with non relational db stuff could be very handy indeed.
So, put down that flamethrower, son, and keep your hands where I can see them.
|
|
|
|
|