<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx</link><description>Introduction and Disclaimer Regular readers of my blog are already familiar with my goal to provide brief and useful information that is approximately correct and that illustrates some key truths. Most of the time my articles are not authoritative and</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>MSDN Blog Postings  &amp;raquo; Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4679271</link><pubDate>Sat, 01 Sep 2007 04:43:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4679271</guid><dc:creator>MSDN Blog Postings  » Database Performance, Correctness, Compostion, Compromise, and Linq too</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://msdnrss.thecoderblogs.com/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too/"&gt;http://msdnrss.thecoderblogs.com/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too/&lt;/a&gt;&lt;/p&gt;</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4679954</link><pubDate>Sat, 01 Sep 2007 05:36:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4679954</guid><dc:creator>bizguy</dc:creator><description>&lt;p&gt;Good analytics, but not code to show samples.&lt;/p&gt;
</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4681293</link><pubDate>Sat, 01 Sep 2007 06:55:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4681293</guid><dc:creator>ricom</dc:creator><description>&lt;p&gt;Sheesh it was already way too long. &amp;nbsp;:)&lt;/p&gt;
</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4682587</link><pubDate>Sat, 01 Sep 2007 08:52:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4682587</guid><dc:creator>kfarmer@microsoft.com</dc:creator><description>&lt;p&gt;I don't see any reason to have code -- it'd distract from the argument.&lt;/p&gt;
</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4688031</link><pubDate>Sat, 01 Sep 2007 16:53:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4688031</guid><dc:creator>Frank Hileman</dc:creator><description>&lt;p&gt;Is it now possible to send an array of parameters to a SP? In generaly, &amp;quot;chunky&amp;quot; communication with a DB (fewer round trips) seems poorly supported in SQL server.&lt;/p&gt;
&lt;p&gt;Now that we have SP that can be written in any CLR language, it would be nice to have better support for sending a chunk of requests to a general purpose SP that can process it in pieces, all on the server, instead of a multitude of round trips.&lt;/p&gt;
&lt;p&gt;While the Linq abstractions are nice, I have a feeling it will further encourage poor practices such as client side joins with large data sets. Linq on the server side SP (written in C#) seems like a great thing.&lt;/p&gt;
</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4690627</link><pubDate>Sat, 01 Sep 2007 20:53:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4690627</guid><dc:creator>ricom</dc:creator><description>&lt;p&gt;Linq to SQL joins are resolved on the server -- the only thing that happens on the client is the coversion to SQL and of course parsing the result set.&lt;/p&gt;
&lt;p&gt;I think you're right about Managed Stored Procedures -- my pet peeve, that you couldn't write procs that accepted arrays conveniently -- is taken care of.&lt;/p&gt;
&lt;p&gt;I never liked TSQL much at all, it's highly useful but not much fun :)&lt;/p&gt;
</description></item><item><title>Referential Integrity</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4715414</link><pubDate>Mon, 03 Sep 2007 06:13:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4715414</guid><dc:creator>Ryan Haney</dc:creator><description>&lt;p&gt;Very interesting article. &amp;nbsp;I am one of those developers that really didn't understand isolation.&lt;/p&gt;
&lt;p&gt;What can you say about sites like MySpace and eBay that move the responsibility of referential integrity to the application level due to the &amp;quot;poor scalability&amp;quot; of database engines? &amp;nbsp;MySpace has supposedly split their DB into sections - i.e. a group of machines serve user data. &amp;nbsp;So users with last names A-E may be on one server, while users with last names F-I may be on another etc. &amp;nbsp;I often wonder if it is because they don't understand the nature of the engine and opt in for the methods they can control.&lt;/p&gt;
</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4716485</link><pubDate>Mon, 03 Sep 2007 07:26:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4716485</guid><dc:creator>Norman Diamond</dc:creator><description>&lt;p&gt;&amp;gt; the only guarantee is that we will get some&lt;/p&gt;
&lt;p&gt;&amp;gt; total that represents the sum of the balances&lt;/p&gt;
&lt;p&gt;&amp;gt; as they could have existed at some moment&lt;/p&gt;
&lt;p&gt;&amp;gt; where all the data was committed.&lt;/p&gt;
&lt;p&gt;The guarantee is less than that. &amp;nbsp;The guarantee is that the total represents the sum of the balances as they could have existed at some moment during some ordering of the transactions which only by accident might happen to match the actual ordering.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;p&gt;You read a bunch of accounts including #1020.&lt;/p&gt;
&lt;p&gt;Someone deposits to #1020.&lt;/p&gt;
&lt;p&gt;Someone else deposits to #1080.&lt;/p&gt;
&lt;p&gt;You read a bunch of accounts including #1080.&lt;/p&gt;
&lt;p&gt;Your total includes the second deposit but not the first. &amp;nbsp;Your total matches a different hypothetical ordering.&lt;/p&gt;
&lt;p&gt;&amp;gt; I wanted to subtract money from #1060 and put&lt;/p&gt;
&lt;p&gt;&amp;gt; in #1070 and everything is great. But what if&lt;/p&gt;
&lt;p&gt;&amp;gt; I had wanted to put the money in account&lt;/p&gt;
&lt;p&gt;&amp;gt; #1030?&lt;/p&gt;
&lt;p&gt;Your scenario has too much 6. &amp;nbsp;Here have a free 3 &amp;nbsp;^_^ &amp;nbsp;... &amp;nbsp;No, that's not enough, because your later sentences have a mix of #1030 and #1060 but lose #1070. &amp;nbsp;Oops, now I have to bite my fingers off to keep from speculating about what company made your database, but maybe I can do more proofreading later.&lt;/p&gt;
</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4724056</link><pubDate>Mon, 03 Sep 2007 16:14:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4724056</guid><dc:creator>Ollie</dc:creator><description>&lt;p&gt;Context is everything :)&lt;/p&gt;</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4726156</link><pubDate>Mon, 03 Sep 2007 20:15:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4726156</guid><dc:creator>ricom</dc:creator><description>&lt;p&gt;Keep in mind my strong admonition that this article is only approximately correct in the name of bevity and clarity.&lt;/p&gt;
&lt;p&gt;The &amp;quot;real&amp;quot; situation would require an entire book if I'm lucky :)&lt;/p&gt;
&lt;p&gt;So don't read too much into the particulars they're simplified for illustration.&lt;/p&gt;
</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4728130</link><pubDate>Mon, 03 Sep 2007 23:11:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4728130</guid><dc:creator>alephnaut</dc:creator><description>&lt;p&gt;I've been doing the database thing for a while now. &amp;nbsp;IMHO it's rare that I need to modify the default transaction isolation level (read committed). &amp;nbsp;I've spent about an equal amount of time in the Oracle and SQL Server worlds and it has still proven true. &amp;nbsp;Almost every app involving concurrency designs its locking strategy with the assumption of basic data integrity (e.g., not reading a partially formed int or double); anything more should be handled at the app level.&lt;/p&gt;
&lt;p&gt;In my experience upping the isolation level has almost always been an indicator of a design problem. &amp;nbsp;A higher level of isolation provides a false sense of security when what's usually needed is for the app design to handle synchronization at a higher level.&lt;/p&gt;
&lt;p&gt;Also, coming from the Oracle world I was baffled by the notion of optimistic concurrency. &amp;nbsp;Maybe it was the lack of a query designer but I assumed that &amp;quot;last one wins&amp;quot; semantics was a given (e.g., updates use only the key field in the where clause). &amp;nbsp;In every place where I saw it used a better approach would have been to push locking to the app level; the first person to get the lock wins, others can't edit until they've released the lock and the lock can timeout.&lt;/p&gt;
&lt;p&gt;I can't agree more with you about database normalization, especially in OLTP type systems. &amp;nbsp;The benefits of a normalized design are similar to the benefits of highly cohesive data structures.&lt;/p&gt;
&lt;p&gt;About bulk inserts and updates, I've found that it's better to push these as close to the server as possible and do it off-line if possible. &amp;nbsp;Use replica tables, update the current secondary then make it the master once it's ready. &amp;nbsp;If it's a periodic thing, say for product catalog updates use BCP if possible (sql loader in the oracle world).&lt;/p&gt;
&lt;p&gt;I'm still deciding about LINQ; every time I've seen attempts to hide the boundary between the OO model and the relational model the result has been an extremely chatty abstraction that doesn't scale and eventually has to be abandoned for high volume applications. &amp;nbsp;From what I've seen, it does look to be useful for replacing boilerplate iteration-filtering code (along the lines of the STL's functions like remove_if).&lt;/p&gt;
</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4729467</link><pubDate>Tue, 04 Sep 2007 00:39:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4729467</guid><dc:creator>ricom</dc:creator><description>&lt;P&gt;Alephanaut is saying two things:&lt;/P&gt;
&lt;P&gt;1) Greater isolation usually isn't needed -- In my experience this is usually true&lt;/P&gt;
&lt;P&gt;2) Moving the locks into the application and then timing out has been a useful technique for him/her. &amp;nbsp;The described technique is a form of the "pessimistic" locking strategy and while it has its place my own feelign is that the opposite approach is appropriate more often. See &lt;A href="http://blogs.msdn.com/ricom/archive/2004/06/24/165063.aspx" target=_new rel=nofollow&gt;http://blogs.msdn.com/ricom/archive/2004/06/24/165063.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This is of course a matter of opinion, and experience in particular environments. YMMV :)&lt;/P&gt;
&lt;P&gt;I think Alephanaut and I substantially agree in our experience other than which locking form has proved more useful to us in our past.&lt;/P&gt;</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4730147</link><pubDate>Tue, 04 Sep 2007 01:13:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4730147</guid><dc:creator>alephnaut</dc:creator><description>&lt;p&gt;To be honest, for the problems I've worked on most of the time last-one-wins has been ok. &amp;nbsp;Reservations have usually only been necessary when the app explicitly involved it (e.g., a content management system or a revision control system where you expect to check things out).&lt;/p&gt;
&lt;p&gt;Or maybe I'm just lazy; update &amp;lt;table&amp;gt; set col=val, ... where &amp;lt;keyfield&amp;gt; = @keyValue is a lot less to type than update &amp;lt;table&amp;gt; set col=val, ... where col1=oldval1 and col2=oldval2 ... especially for tables with a lot of fields :)&lt;/p&gt;
</description></item><item><title>re: Database Performance, Correctness, Compostion, Compromise, and Linq too</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#4732600</link><pubDate>Tue, 04 Sep 2007 04:53:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4732600</guid><dc:creator>ricom</dc:creator><description>&lt;p&gt;Linq gives you optimistic locking automatically, no typing :)&lt;/p&gt;
</description></item><item><title>Getting Started With LINQ To SQL</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#7819874</link><pubDate>Wed, 20 Feb 2008 19:04:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7819874</guid><dc:creator>Hilton Giesenow's Jumbled Mind</dc:creator><description>&lt;p&gt;Considering I&amp;amp;#39;ve put a few posts up about LINQ To SQL, I realised I&amp;amp;#39;ve never shared some of the&lt;/p&gt;
</description></item><item><title>Getting Started With LINQ To SQL(转)</title><link>http://blogs.msdn.com/ricom/archive/2007/08/31/database-performance-correctness-compostion-compromise-and-linq-too.aspx#8350088</link><pubDate>Wed, 02 Apr 2008 09:50:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8350088</guid><dc:creator>王德水</dc:creator><description>&lt;p&gt;原文地址:&lt;a rel="nofollow" target="_new" href="http://dotnet.org.za/hiltong/archive/2008/02/20/getting-started-with-linq-to-sql.aspxConsideri"&gt;http://dotnet.org.za/hiltong/archive/2008/02/20/getting-started-with-linq-to-sql.aspxConsideri&lt;/a&gt;...&lt;/p&gt;
</description></item></channel></rss>