Posted by
Scott
on
20. October 2008 16:22
When life throws you hard balls, you can either step back
and take a swing or bunt the hell out of it. I just recently went to an
information session on T-SQL, Stored Procedures and now LINQ. These folks
discussed stored procedures and why they are so important in the world today.
They stated ideas such as:
- Stored
Procedures optimize queries.
- They
stop SQL Injection attacks.
- Stored
procedures are concrete and cannot be changed.
I wanted to briefly state a
counter argument against stored procedures and for T-SQL and LINQ:
- Stored
procedures do not optimize queries.
- A
SP is not an optimized query, it does not save time. SP’s used to save time and have been faster in
the past, but more and more RAD development has been done without SP’s. The development has caught up with SP’s and dynamic SQL has now caught up and in some cases surpassed SP’s. These days
parameterized queries are now cached just like SP’swhich put them on an even playing field.
- Microsoft
LINQ and ADO
teams both admit that SP’s are not faster
than dynamic SQL.
- Benchmarks
have also been completed which explicitly show SP's
are slower over small queries and tie dynamic queries over larger ones.
- Stored
procedures do stop injection attacks, but you can also do it with
parameterized queries.
- SP’s are good at this, but it can also be done
with parameters. Putting a value into a parameter means that it
will not be a part SQL query string at all.
- Stored
procedures are very concrete and are hard to change as a developer with a
DBA. This is the problem.
- As
a developer when you push a product out the door, you want to be fast at
this. Developers don’t want to learn two languages in order
for their product to be pushed out the door and then go back to the
database every time code needs to be changed. They want dynamic
abilities. When SP’s are hard to
change, it might be a bit harder and take longer when you have a
DBA. The inability for SP’s to be
changed or created fast is the issue with this kind of development.
- SP’s mangle the three tier
architecture designed for apps.
- Instead
of having a structure which separates logic from storage, you have
storage and logic on the same tier. This will cause potential
problems down the road.
- Business
logic in a SP does not scale. Business logic should be in code and
not in the storage center.
- When
you have multiple database servers, it is more difficult to keep the
triggers and SP’s synced.
- There
is no Version Control for SP’s.
- In
a place that can be disastrous if you screw up, it should have something.
This is one big reason why people like to avoid SP’s
like the plague. They run away and never move back into town.
If you see the new technologies coming
out of Microsoft now, there will be no need for SP’s
in the future. LINQ is taking care of most of this by allowing for a data
layer cheaply and efficiently with very little effort by the developer. LINQ
handles all these problems and if you truly like a confirmation on all the
things I said, just search the internet for Stored Procedures v.s. Dynamic SQL.
The debate these days has two
sides. Not “Republican or Democrat”, but “Progressive and
Non-Progressive”. The Progressive folks are not using Stored
Procedures these days.

If you liked this post, please be sure to subscribe to my
RSS Feed.
Posted by
Scott
on
2. October 2008 14:18
I needed to get a query completed like this in LINQ.
Select max(uid) as uid, Serial_Number from Table Group BY Serial_Number
I thought about it for a while but didn't get anywhere. I kept testing until I asked another person and they came up with:
using (DataContext dc = new DataContext())
{
var q = from t in dc.TableTests
group t by t.SerialNumber
into g
select new
{
SerialNumber = g.Key,
uid = (from t2 in g select t2.uid).Max()
};
}
This code is very nice and sweet. It allows you to select the all MAX Rows of a table with a grouped table column.
Hope you enjoyed this little lesson. I decided to save this syntact because it is something I will most likely come accross again.
Scott
If you liked this post, please be sure to subscribe to my
RSS Feed.
Posted by
scott
on
19. May 2008 01:01
A few weeks ago, I had the chance to attend DevConnections 2008 in Orlando, FL. I spoke to a Microsoft Pro by the name of Steven Toub. He works for Microsoft in the parallel computing labs. He currently is designing PLINQ which is a parallel operations for LINQ. He said in the next 9 years, he expects 100 Core machines to be out on the market and Microsoft has vowed NOT to make any software for 32 bit machines anymore from today on.
It is interesting to see Microsoft take this route and not develop for single cores anymore and I am questing what can that do for their market. I only think make it better. There are rumors out there that Microsoft doesn't innovate anymore. I think some of the rumors are true to some markets of software, but in other markets Microsoft leads the pack. Microsoft does have a problem with its Internet technology and they just released Microsoft Mesh which allows for a computer desktop to be visualized on the Internet Browser. Pretty impressive stuff which shows that they can innovate in some areas, but very little in others. I think the main reason Microsoft doesn't innovate as much in Americans eyes nor in the Europeans eyes because they are in disgust of the the giant gorilla in the room and there for less and less Americans go to work for them. Its all about Yahoo and Google and working for those folks. Americas top innovators have moved from Microsoft to Google in a big jump that took about 5 years. They saw that Google actually had money to spend and it is also a great place to work. I don't know about Microsoft's working conditions, but Google is supposedly the cream of the crop for developers.
The entire discussion is wether Microsoft can still innovate in the next couple of years. I for one enjoy Microsoft's products and the PLINQ will be a gem for them that Google doesn't currently have yet.
Can Microsoft keep up with the Innovations?
If you liked this post, please be sure to subscribe to my
RSS Feed.
Posted by
Scott
on
23. April 2008 19:34
Boy am I tired. I can literally say I am exhausted. Now here is why. Sessions today were AMAZING and today was a good day because yesterday I found a programmer just like me who is as young as I am who wants to start up his own company just like I do. I am not telling you his name, but I got his contact information and will be giving him a ring ding ding soon! Anyone else interested in helping me with my ideas? I am poor and don't pay until we actually produce something, but I am looking for some takers. I don't mind splitting 60-40 or even starting a small business with employees. It will NOT be a consulting business, too many of those floating around. I want to start a business with my own ideas and make them a reality. Any takers?
Sessions Attended:
Building Custom AJAX Controls:
Taught by Dan Wahlin. If you have ever met him, he is as tall as me and married. One question I asked him personally is how he gets so much done and his wife be okay with it, when I have a girlfriend of my own. He said she gets used to it. This guy is also pretty interesting and pretty informed on the subject of ASP.NET. I enjoyed this session, because the JavaScript he taught was pretty much down to my level of understanding. He hit the topics of web services and JavaScript debugging in Visual Studio. He hit on the things to do when your starting up a new JavaScript file and make sure it talks to ASP.NET. Cool session, but far too much to be explained here.
Building N-Tier Applications with LINQ:
Taught again by Dan Wahlin. Another great session about how to implement LINQ into your projects and showed the easy parts of LINQ which only gets easier from T-SQL. Thank you Dan for this great session. It is a lot to implement in this short session.
Can you tell I am getting tired?
PLINQ: LINQ but faster:
Taught by the one and only Stephen Toub. The same guy I met last night is now teaching a session. I didn't know much about what he was talking about last night, but when he hit on it today in the session, I WAS BLOWN AWAY. So, he has got this 24 CORE computer up in Washington that he ran demos for us on. If you don't know what LINQ is I should ask that you check it out. PLINQ is the next step up and which you can select and transfer data at tremendous speeds using the processors that a person has in their computer. He completed a select statement with one processor with 256mbs worth of data and took about 20 seconds. The second select statement was with PLINQ with the same amount of data and the select completed at .5 seconds. Amazing STUFF. This kind of data selects could be used for gaming and even the Folding@Home project where they use personal computers from all around the world to fold protein. Amazing things if they only had their hands on this.
.NET Rocks:
Live interview with Dan Wahlin. I screamed a few times and asked the first question. Great interview and good times thanks to Carl Franklin, Richard Campbell and Dan Wahlin.
Time to Go home. Thanks for reading. More to follow.
Side Note: I am required by my company to do a "What I learned" white paper. I will post it to this blog when done, because it will contain a lot of things that I thought would be too detailed to explain in these entries.
If you liked this post, please be sure to subscribe to my
RSS Feed.
Posted by
scott
on
4. April 2008 01:12
So here I am building a new site that will estimate around 500,000 page views and 50,000 database transactions DAILY. I am currently working on a simple query that selects ONE row[column] from a database and returns the value to the rest of the methods. I have a simple thought or question I would like answered and thought this would be a place to bring it up.
Is the foreach loop required even if I know I will receive only 1 record back from the database?
That's it and to give you an example:
CS_Code.DataContext db = new CS_Code.DataContext(SQLStatementsCS.ConnectionStringID());
var query = from RN in db.Province
where RN.Name == Name
select RN.uid;
int value;
foreach (var uid in query)
{ value = uid; }
I think it is kind of pointless to create a foreach loop and use 3 lines of code to just get an ID out of the database. So let me know in the comments section if this is the only answer and I will point out the answer and give you a link back to a site of your choice.
Thanks guys and dolls.
Posted by
Scott
on
16. March 2008 17:20
Since Linq came out people have been working hard on the application. I found a great application that supports linq queries pretty well. I am happy to see development come out of new microsoft technology. The application is called Linqpad and I just wanted to point that out. I thought these things need to be pointed out when new technologies came about.