<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Tech Crumb</title>
	<atom:link href="http://sarosh.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sarosh.wordpress.com</link>
	<description>Crumbs collected along the way  ....</description>
	<lastBuildDate>Sat, 09 Jan 2010 15:34:07 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='sarosh.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/352d4b1f09fa5f71194b178d26807c02?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tech Crumb</title>
		<link>http://sarosh.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://sarosh.wordpress.com/osd.xml" title="Tech Crumb" />
	<atom:link rel='hub' href='http://sarosh.wordpress.com/?pushpress=hub'/>
		<item>
		<title>B i l l i o n strings falling from c l o u d</title>
		<link>http://sarosh.wordpress.com/2009/12/25/billion-strings-falling-from-cloud/</link>
		<comments>http://sarosh.wordpress.com/2009/12/25/billion-strings-falling-from-cloud/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 17:05:07 +0000</pubDate>
		<dc:creator>Rafat Sarosh</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[.NET 4.0 SQL Parallel computing]]></category>
		<category><![CDATA[Multi core]]></category>

		<guid isPermaLink="false">http://sarosh.wordpress.com/?p=166</guid>
		<description><![CDATA[Everyday, we have to process almost a Billion strings from our click stream store. To keep things simple, let’s say I get the URL and I need to parse the domain name from string. For example: if the URL is as follows:
http://www.microsoft.com/Downloads.
Then I need to parse this string and get the domain name “www.microsoft.com”.
Looking at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=166&subd=sarosh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Everyday, we have to process almost a Billion strings from our click stream store. To keep things simple, let’s say I get the URL and I need to parse the domain name from string. For example: if the URL is as follows:</p>
<p>http://www.microsoft.com/Downloads.</p>
<p>Then I need to parse this string and get the domain name “www.microsoft.com”.</p>
<p>Looking at the parallel libraries of .NET 4.0,  I thought to use them and increase our data crunching performance. I planned to use Parallel.ForEach in place of foreach  to harness all the CPU cores of my box.</p>
<p>However, to my amazement, <strong> I realized that using parallel version of foreach is taking more time than the single thread version of foreach</strong>. After little head scratching, I realized the work in my foreach loop was so small that cost of creating thread and destroying them was more than the work they need to do them self. It is like if the work is small enough that explaining someone to do it will take more time than actually doing it, sometime parallel processing and delegating work is not good.</p>
<p>However, as soon as I put heavy processing in the loop, for e.g. making the thread sleep for 10 millisecond :), my parallel version started performing better than the single threaded version of foreach.</p>
<p>Here is the code I wrote to do the parallel parsing:</p>
<pre class="brush: csharp;">

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Threading;

namespace DP_Parallel
{
class Program
{
static void Main(string[] args)
{
 List str = new List();
 using (AdventureWorksEntities AwContext = new AdventureWorksEntities())
 {
  IEnumerable uri = AwContext.ClickStreams
  .Where(u =&gt; u.ReferringURI.Length &gt; 0)
  .Select(u =&gt; u.ReferringURI)
     .Take(1000000);

     //Parallel
     Parallel.ForEach
  (uri, (string s) =&gt;
     {
      int Pos = s.IndexOf(@&quot;/&quot;, 8) - 7;
      if (Pos &gt; 5)
      {
        //Thread.Sleep(10);
       str.Add(s.Substring(7, Pos))  ;
       //Some other processing on the string - upper case etc
      }
     }
    );
   }
  }
 }
}
</pre>
<p>For a million rows C# non parallel code took 8.67 second, whereas Parallel version took 1 Minute and 1.51 second, but only 16 second in SQL with the following query</p>
<pre class="brush: sql;">
print cast ( getdate() as time )
SELECT  TOP 1000000
  case CHARINDEX ( '/', [referringURI], 8 )
  when 0 then ReferringURI
  else substring ( [ReferringURI] , 8, (CHARINDEX ( '/', [referringURI], 8)  ) - 8)
  end as DomainName
   into #T
  FROM [StagerDW].[dbo].[ClickStream] where len (ReferringURI) &gt; 0
print cast ( getdate() as time )
 </pre>
<p>So for just this task, C# code is twice as efficient over SQL and  many fold over the parallel code. But, as I said if you have to do a little heavy processing than parallel code may win over the single thread code.  So the best option to write a CLR Stored procedure in SQL, and from the CLR code enjoy the multi core parallel processing advantages.</p>
<p>yes, we don&#8217;t wait whole day to process the billion rows but crunch them as they come in &#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarosh.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarosh.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarosh.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarosh.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarosh.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarosh.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarosh.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarosh.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarosh.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarosh.wordpress.com/166/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=166&subd=sarosh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://sarosh.wordpress.com/2009/12/25/billion-strings-falling-from-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8e93bef927d029c824b91da0b59f703?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">rsarosh</media:title>
		</media:content>
	</item>
		<item>
		<title>AsParallel makes your query topless</title>
		<link>http://sarosh.wordpress.com/2009/12/25/asparallel-makes-your-query-topless/</link>
		<comments>http://sarosh.wordpress.com/2009/12/25/asparallel-makes-your-query-topless/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 02:11:15 +0000</pubDate>
		<dc:creator>Rafat Sarosh</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[PLINQ]]></category>
		<category><![CDATA[Multi core]]></category>
		<category><![CDATA[Entity framework]]></category>
		<category><![CDATA[NET 4.0]]></category>

		<guid isPermaLink="false">http://sarosh.wordpress.com/?p=145</guid>
		<description><![CDATA[Here is a simple code snippet using Entity framework:



using (AdventureWorksEntities AwContext = new AdventureWorksEntities())
 {
   var LoginId = AwContext.Employees
            .Where ( u =&#62; u.LoginID.Length &#62; 0 )
            .Select(u =&#62; u.LoginID)
  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=145&subd=sarosh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a simple code snippet using Entity framework:</p>
<div>
<pre class="brush: csharp;">

using (AdventureWorksEntities AwContext = new AdventureWorksEntities())
 {
   var LoginId = AwContext.Employees
            .Where ( u =&gt; u.LoginID.Length &gt; 0 )
            .Select(u =&gt; u.LoginID)
            .Take(10);
</pre>
</div>
<p>As you can see from the above code, I am trying to get the top 10 rows from Employee table and only one column LoginID, where loginID length is more than zero. If you fire this query you may get a SQL in SQL Profiler as follows:</p>
<div>
<pre class="brush: sql;">
SELECT TOP (10)
      [c].[LoginID] AS [LoginID]
        FROM [HumanResources].[Employee] AS [c]
            WHERE LEN( [c].[LoginID] ) &gt; 0
</pre>
</div>
<div>Now, web is full of examples of how to take advantage of multiple cores  and make your query run in parallel by using PLINQ.  Just add magic word AsParallel in front of the data source and your code will take advantage of multi core and run in multi thread . But if you are developer who read 5000 words a minute, you may miss the fact that PLINQ applies only to LINQ to objects (i.e. IEnumerable-based sources where lambdas are bound to delegates, not IQueryable-based sources where the lambdas are bound to expressions) and you may add AsParallel in your query thinking that you are using multi core of your CPU and some how your query will become faster. Unfortunately your code may still  work, but now it has sever side effects behind the scene.</div>
<div>
<div>
<pre class="brush: csharp;">
&lt;pre&gt;using (AdventureWorksEntities AwContext = new AdventureWorksEntities())&lt;/pre&gt;
 {
 var LoginId = AwContext.Employees.AsParallel
 .Where ( u =&gt; u.LoginID.Length &gt; 0 )
 .Select(u =&gt; u.LoginID)
 .Take(10);
</pre>
</div>
<div>With luck your code may still work, but under the cover many things have changed. First one is your <span style="text-decoration:underline;">Top 10 selection is gone</span> from the query which goes to SQL. This can be a problem if your table is large with couple of millions rows. Second, now you are getting all the columns. Third, if you are lucky then you may get some exceptions in  the code as other threads try to process your rest of statements like ‘Where’ clause and they break up with the Null Reference exception else you will just squander the resources in the false pretext that you have written an efficient code. Here is the SQL generated after adding the &#8216;AsParallel&#8217;  keyword.</div>
<div>
<pre class="brush: sql;">
SELECT
   [Extent1].[EmployeeID] AS [EmployeeID],
   [Extent1].[NationalIDNumber] AS [NationalIDNumber],
   [Extent1].[ContactID] AS [ContactID],
   [Extent1].[LoginID] AS [LoginID],
..all other columns
     FROM [HumanResources].[Employee] AS [Extent1]
         WHERE LEN( [c].[LoginID] ) &gt; 0
</pre>
</div>
<div>
<p>So remember, LINQ-to-SQL and LINQ-to-Entities queries will be executed by the respective databases and query providers, PLINQ does not offer a way to parallelize those queries. However,  If you wish to process the results of those queries in memory, including joining the output of many heterogeneous queries, then PLINQ can be quite useful.</p>
</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarosh.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarosh.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarosh.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarosh.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarosh.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarosh.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarosh.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarosh.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarosh.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarosh.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=145&subd=sarosh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://sarosh.wordpress.com/2009/12/25/asparallel-makes-your-query-topless/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8e93bef927d029c824b91da0b59f703?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">rsarosh</media:title>
		</media:content>
	</item>
		<item>
		<title>XMLTextWriter v/s XElement</title>
		<link>http://sarosh.wordpress.com/2009/09/29/xmltextwriter-vs-xelement/</link>
		<comments>http://sarosh.wordpress.com/2009/09/29/xmltextwriter-vs-xelement/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 08:19:00 +0000</pubDate>
		<dc:creator>Rafat Sarosh</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://sarosh.wordpress.com/2009/09/29/xmltextwriter-vs-xelement/</guid>
		<description><![CDATA[I have to move some data from Database to a XML file. A very simple task, write a SQL query, get the result and put it into a XML File. So here is my data query


DownloadDataContext db = new DownloadDataContext();
IQueryable downloads =
      from f in db.Files
      join fr in db.FamilyReleases
          on f.ReleaseID equals fr.ReleaseID 
      join [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=137&subd=sarosh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I have to move some data from Database to a XML file. A very simple task, write a SQL query, get the result and put it into a XML File. So here is my data query</p>
<pre class="brush: csharp;">

DownloadDataContext db = new DownloadDataContext();
IQueryable downloads =
      from f in db.Files
      join fr in db.FamilyReleases
          on f.ReleaseID equals fr.ReleaseID 
      join fdl in  db.FamilyDetailsByLocales
          on fr.FamilyID equals fdl.FamilyID
              select new DownloadDetails{
                FamilyID = fdl.FamilyID,
                FileName = f.FileName,
                FileSize = f.FileSize, URL = f.URL
)
</pre>
<p>Once I got the data in IQueryable downloads, Out of old habit, I proceeded to make the XML as follows:</p>
<pre class="brush: csharp;">
MemoryStream ms = new MemoryStream();
using (XmlTextWriter w = new XmlTextWriter( ms, Encoding.UTF8 )) {
     w.Formatting = Formatting.Indented;
     w.WriteStartElement(&quot;Products&quot;);
           foreach (DownloadDetails d in downloads) { 
          w.WriteStartElement(&quot;FamilyID&quot;); w.WriteValue(d.FamilyID.ToString());                                

w.WriteEndElement(); w.WriteStartElement(&quot;FileName&quot;); w.WriteValue(d.FileName ); w.WriteEndElement(); w.WriteStartElement(&quot;FileSize&quot;); w.WriteValue(d.FileSize); w.WriteEndElement(); w.WriteStartElement(&quot;URL&quot;); w.WriteValue(d.URL); w.WriteEndElement(); }
w.WriteEndElement(); //products
}
StreamReader r = new StreamReader(ms,Encoding.UTF8);
ms.Seek(0, SeekOrigin.Begin);
return r.ReadToEnd();
</pre>
<p>Very simple, However when I check the returned XML string,  it is always cut in between and a proper XML is not formed. As the data is localized there may be a possibility that there is some funny character came in between and stream reader <em>ReadToEnd </em>function got confused. Debugging with 40+ languages in data was a nightmare, and I had no clue why streamreader is not working as it is suppose to work. There were other problems too, If any of the values are null, <em>TextWriter.WriteValue</em> complain very loudly. So every where I have to put a check to see if the value is null or not. However, the XElement came to my rescue. XElement does take all the possible data types, and does not complain if any of the data type is null.</p>
<pre class="brush: csharp;">

XElement x = new XElement(&quot;Products&quot;);
foreach (DownloadDetails d in downloads) {
x.Add(new XElement(&quot;Product&quot;,
new XElement(&quot;FamilyID&quot;, d.FamilyID.ToString()),
new XElement(&quot;FileName&quot;, d.FileName),
new XElement(&quot;FileSize&quot;, d.FileSize),
new XElement(&quot;URL&quot;, d.URL + &quot;&quot;))); }
</pre>
<p>XElement not only handles NULL gracefully but does not complain about any of the unknown characters which threw StreamReader off. Clearly XElement is a better choice to make  XML out of data, <a href="http://sarosh.wordpress.com/2009/06/17/access-mdb-to-xml-with-linq/" target="_blank">here </a>is another example of XElement use.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarosh.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarosh.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarosh.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarosh.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarosh.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarosh.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarosh.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarosh.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarosh.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarosh.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=137&subd=sarosh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://sarosh.wordpress.com/2009/09/29/xmltextwriter-vs-xelement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8e93bef927d029c824b91da0b59f703?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">rsarosh</media:title>
		</media:content>
	</item>
		<item>
		<title>Difference between facade and Decorator Pattern</title>
		<link>http://sarosh.wordpress.com/2009/09/22/difference-between-facade-and-decorator-pattern/</link>
		<comments>http://sarosh.wordpress.com/2009/09/22/difference-between-facade-and-decorator-pattern/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 23:52:26 +0000</pubDate>
		<dc:creator>Rafat Sarosh</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Pattern]]></category>

		<guid isPermaLink="false">http://sarosh.wordpress.com/2009/09/22/difference-between-facade-and-decorator-pattern/</guid>
		<description><![CDATA[Yesterday, I was discussing with our friends about pattern and differences between facade and decorator pattern? Facade gives the impression that your create a facade object over different desperate objects, or you actually decorate them with another layer, or they are two different name for the same pattern etc. All kind of confusion was there, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=129&subd=sarosh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I was discussing with our friends about pattern and differences between facade and decorator pattern? Facade gives the impression that your create a facade object over different desperate objects, or you actually decorate them with another layer, or they are two different name for the same pattern etc. All kind of confusion was there, because of the name, I noticed people get confused between these two pattern, not the one who understand both the pattern well, but the people who read about them last year and did not understand them well.</p>
<p>With this blog entry, I want to make sure that you will never ever forget their definition and never get mixed up between these two patterns.</p>
<blockquote><p><a href="http://en.wikipedia.org/wiki/Decorator_pattern" target="_blank">Decorator pattern</a> is a design pattern that allows new/additional behavior to be added to an existing class dynamically. Decorators provide a flexible alternative to sub classing for extending functionality.</p></blockquote>
<p>The decorator pattern can be used to make it possible <strong>to extend (decorate) the functionality of a class at runtime</strong>. Taking the example from Allan Shalloway book, <a href="http://www.amazon.com/Design-Patterns-Explained-Perspective-Object-Oriented/dp/0201715945" target="_blank">Design patterns explained</a>. Suppose you have to print a SalesTicket, and depending up on sales, you may need to print multiple headers and multiple footers. Decorator pattern helps you control headers, by chaining together the headers desired in the correct order.</p>
<p>Header1-&gt;Header2-&gt;Header3-&gt;Concrete Component.</p>
<p><a href="http://sarosh.files.wordpress.com/2009/09/beadneckles2.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;margin:0 10px 0 0;" title="beadneckles2" src="http://sarosh.files.wordpress.com/2009/09/beadneckles2_thumb.jpg?w=136&#038;h=164" border="0" alt="beadneckles2" width="136" height="164" align="left" /></a> The Decorator pattern separates the dynamic building of this chain of functionality from the client. It will also separates the building of the chain from the chain components (Header and Footer).</p>
<p>Now, here is a way to remember it forever, a different way to think is, <em>Decorator pattern help decorate</em>. decorator pattern help us create  necklaces with different bead color combinations.  <strong>Decorator pattern is chain of objects.</strong> To achieve this you wrap the original bead class with a decorator class.</p>
<p>Suppose we need to write a program, which make different necklaces with different color combinations of beads. Because of decorator pattern it is fairly easy to build the different necklaces and the change in code can be limited to factory class.</p>
<p> </p>
<p>Here is the code:</p>
<pre class="brush: csharp;">
using System;

namespace Decorator
{

///
/// The Beads abstract class
///

abstract class Beads
{
        public abstract void MakeNecklace();
}

///
/// The 'ConcreteComponent' class
///

class ConcerteBead : Beads
{

public override void MakeNecklace()
{
         Console.WriteLine(&quot;ConcreteBead&quot;);
}
}

///
/// The 'Decorator' abstract class
///

abstract class Decorator : Beads
{
      protected Beads beads;
      public Decorator(Beads _beads)
     {
           this.beads = _beads;
     }
    public Decorator()
   {
    }

 public override void MakeNecklace()
 {
       if (beads != null)
     {
         beads.MakeNecklace();
      }
 }
}

class RedBeads : Decorator
{
       public RedBeads(Beads _beads)
      {
           beads = _beads;
        }
       public override void MakeNecklace()
      {
          base.MakeNecklace();
         Console.WriteLine(&quot;RED&quot;);
     }
}

class GreenBeads : Decorator
{
         public GreenBeads(Beads _beads)
        {
              beads = _beads;
        }
        public override void MakeNecklace()
       {
          base.MakeNecklace();
          Console.WriteLine(&quot;GREEN&quot;);
        }
}

class WhiteBeads : Decorator
{
        public WhiteBeads(Beads _beads)
       {
           beads = _beads;
        }
         public override void MakeNecklace()
         {
            base.MakeNecklace();
            Console.WriteLine(&quot;WHITE&quot;);
         }
}

class Program
{
        static void Main()
       {
           Beads beads = BeadFactory(true);
           beads.MakeNecklace();
           Console.ReadKey();
       }

private static Beads BeadFactory(bool Colorful)
{
           if (Colorful)
         {
                return new GreenBeads(new RedBeads(new WhiteBeads(new ConcerteBead())));
          }
else
        {
              return new WhiteBeads(new WhiteBeads(new WhiteBeads(new ConcerteBead())));

       }
  }
 }
}
</pre>
<p>The output of the above code will be:</p>
<p>Concrete Bead<br />
WHITE<br />
RED<br />
GREEN</p>
<p> </p>
<p>To decouple client from the chain of object,  a factory objects can instantiate the chains based upon some configuration information.  Instantiation of the chains of objects is completely decoupled from the Client<a name="typically accomplished"></a> objects that use it. Decorator Allows for extending the functionality of an object without resorting to subclassing.</p>
<p>May be tomorrow we will talk about Facade pattern.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarosh.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarosh.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarosh.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarosh.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarosh.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarosh.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarosh.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarosh.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarosh.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarosh.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=129&subd=sarosh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://sarosh.wordpress.com/2009/09/22/difference-between-facade-and-decorator-pattern/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8e93bef927d029c824b91da0b59f703?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">rsarosh</media:title>
		</media:content>

		<media:content url="http://sarosh.files.wordpress.com/2009/09/beadneckles2_thumb.jpg" medium="image">
			<media:title type="html">beadneckles2</media:title>
		</media:content>
	</item>
		<item>
		<title>Suddenly working system performance nose dived, now what?</title>
		<link>http://sarosh.wordpress.com/2009/09/17/index-name/</link>
		<comments>http://sarosh.wordpress.com/2009/09/17/index-name/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 21:49:16 +0000</pubDate>
		<dc:creator>Rafat Sarosh</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://sarosh.wordpress.com/2009/09/17/index-name/</guid>
		<description><![CDATA[We had a ETL process, which used to process a small table of thirty million records a time. These records were moved in a staging table for the extensive processing. Once the processing completes, we truncate the staging table and get the data for the next day.
The system ran fine for couple of days, then [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=118&subd=sarosh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>We had a ETL process, which used to process a small table of thirty million records a time. These records were moved in a staging table for the extensive processing. Once the processing completes, we truncate the staging table and get the data for the next day.</p>
<p>The system ran fine for couple of days, then suddenly the ETL processed slowed and the ETL complete time increased by many folds, from 15 minutes it reached to four hours or so.</p>
<p>Our first attempt to find the cause of slow query performance was to check the Query plan. There I noticed that we are using an Index Lookup.</p>
<p>
<pre class="brush: sql;">   SELECT @DLStartTime = MIN(DownloadTime)      FROM etl.VLSCRawDataFromStager(nolock)      WHERE (DownloadURI = @DownloadURI AND ASID = @ASID) OR TransactionID = @TransactionId&lt;/p&gt;  &lt;p&gt;</pre>
</p>
<p>We had couple of non-clustered indexes on DownloadURI, ASID and on TransactionId. And a clustered Index on RowId. Looking at the query, you may think the query must be using these simple non-crusted indexes to get the DownloadTime. However, the Query plan looks like as follows:</p>
<p><a href="http://sarosh.files.wordpress.com/2009/09/execution.jpg"><img style="display:inline;border-width:0;" title="execution" border="0" alt="execution" src="http://sarosh.files.wordpress.com/2009/09/execution_thumb.jpg?w=600&#038;h=300" width="600" height="300" /></a> </p>
<p>&#160;</p>
<p>Query is using the key lookup operator. <strong>The use of a Key Lookup operator in a query plan indicates that the query might benefit from performance tuning.</strong> For example, query performance might be improved by adding a covering index. read more on <a title="http://msdn.microsoft.com/en-us/library/bb326635.aspx" href="http://msdn.microsoft.com/en-us/library/bb326635.aspx">http://msdn.microsoft.com/en-us/library/bb326635.aspx</a></p>
<p>Detail of two non-clustered indexes seeks, output shows as&#160; ‘RowId’ and then this ‘RowId’ is used in turn to do a Key lookup on clustered Index for the output ‘DownloadTime’. Key lookup fetches the extra columns from the clustered index when the non clustered index that’s used to retrieve the rows doesn’t have all the columns required. </p>
<p>Bookmark lookup is not a cheap operation. The&#160; plan can be improved by&#160; adding one or more columns to an existing index so as to eliminate a bookmark lookup, in SQL Server 2005 onwards, you can add columns using the include clause of the create index statement.&#160; Included columns are more efficient than key columns; they save disk space and make searching and updating the index more efficient.&#160; SQL decide on the query plan depending on the number of rows returned. Read more on </p>
<p><a title="http://sqlserverpedia.com/blog/sql-server-bloggers/key-lookup-threshold/comment-page-1/" href="http://sqlserverpedia.com/blog/sql-server-bloggers/key-lookup-threshold/comment-page-1/">http://sqlserverpedia.com/blog/sql-server-bloggers/key-lookup-threshold/comment-page-1/</a>     <br /><a title="http://blogs.msdn.com/craigfr/archive/2006/06/30/652639.aspx" href="http://blogs.msdn.com/craigfr/archive/2006/06/30/652639.aspx">http://blogs.msdn.com/craigfr/archive/2006/06/30/652639.aspx</a></p>
<p>We modified one of the index and included other columns.</p>
<p>
<pre class="brush: sql;"> CREATE NONCLUSTERED INDEX [VLSCRawDataFromStager_ndx2] ON [etl].[VLSCRawDataFromStager]    (  [DownloadTime] ASC,  [DownloadURI] ASC,  [ASID] ASC,  [TransactionID] ASC   )     &lt;br /&gt;GO&lt;/p&gt;  &lt;p&gt;</pre>
</p>
<p>This change removed the Key lookup from the query plan, and suddenly our performance increased by many fold.</p>
<p>It worked for few hours, but before our celebration beer can become warm, the performance again tanked. Now what? </p>
<p>What the hell happened?&#160; For every run we are truncating the tables, and the system ran fine for weeks, now it is tanking, specially when we removed the nasty key lookup. We thought we improved the system but system performance is not improved.</p>
<p>Now, I used <strong>sys.dm_db_index_physical_stats </strong>check the indexes<strong>, </strong>this returns fragmentation information for the data and indexes of the specified table or view. </p>
<p>
<pre class="brush: sql;"> select * from sys.dm_db_index_physical_stats (DB_ID(N'DataBaseName'), OBJECT_ID(N'TableName'), NULL, NULL , NULL); </pre>
</p>
<p>and of course we see the indexes are fragmented more then 95%. I&#160; realized the <strong>truncate table statement does not get rid of Indexes</strong>, TRUNCATE TABLE removes all rows from a table, but the table structure and its columns, constraints, indexes and so on remain. read more <a title="http://msdn.microsoft.com/en-us/library/aa260621(SQL.80).aspx" href="http://msdn.microsoft.com/en-us/library/aa260621(SQL.80).aspx">http://msdn.microsoft.com/en-us/library/aa260621(SQL.80).aspx</a></p>
<p>Overlooking this fact threw us in wrong direction, else this is the first thing we should be checking, but we thought truncate table is cleaning the indexes too, which turn out not be the case. However, the simple fix was to get rid of indexes too, and recreate them after every truncate. This fix bought our ETL performance back to acceptable level.</p>
<p>&#160;</p>
<p>P.S</p>
<p>However the result set from <strong>sys.dm_db_index_physical_stats </strong>has index_id and object_id as the column name. You may waste few minutes to write query to get the index name from these ids.&#160; So here is the query: </p>
<pre class="brush: sql;"> select i.*, stat.* from sys.dm_db_index_physical_stats (DB_ID(N'DataBaseName'), OBJECT_ID(N'TableName'), NULL, NULL , NULL) stat join sys.indexes i on i.object_id = stat.object_id and i.index_id = stat.index_id </pre>
<p>OBJECT_ID is evaluated in the current database context, not in the context of the database which you specified in for DB_ID. If the current database does not have the table, then Object_ID will return NULL and your result will be wrong</p>
<p>To get all the indexes in a database it is simply:</p>
<pre class="brush: sql;"> select i.*, stat.* from sys.dm_db_index_physical_stats (DB_ID(N'AdventureWorks'), NULL, NULL, NULL , NULL) stat join sys.indexes i on i.object_id = stat.object_id and i.index_id = stat.index_id where stat.avg_fragmentation_in_percent &amp;gt; 10   &lt;p&gt;&lt;/p&gt; </pre>
</p>
<p>Read more at <a title="http://msdn.microsoft.com/en-us/library/ms188917.aspx" href="http://msdn.microsoft.com/en-us/library/ms188917.aspx">http://msdn.microsoft.com/en-us/library/ms188917.aspx</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarosh.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarosh.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarosh.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarosh.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarosh.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarosh.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarosh.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarosh.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarosh.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarosh.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=118&subd=sarosh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://sarosh.wordpress.com/2009/09/17/index-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8e93bef927d029c824b91da0b59f703?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">rsarosh</media:title>
		</media:content>

		<media:content url="http://sarosh.files.wordpress.com/2009/09/execution_thumb.jpg" medium="image">
			<media:title type="html">execution</media:title>
		</media:content>
	</item>
		<item>
		<title>Temp Table Variable v/s Temp table</title>
		<link>http://sarosh.wordpress.com/2009/09/16/temp-table-variable-vs-temp-table/</link>
		<comments>http://sarosh.wordpress.com/2009/09/16/temp-table-variable-vs-temp-table/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 21:01:58 +0000</pubDate>
		<dc:creator>Rafat Sarosh</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL SQL Performance]]></category>

		<guid isPermaLink="false">http://sarosh.wordpress.com/2009/09/16/temp-table-variable-vs-temp-table/</guid>
		<description><![CDATA[We know that using Temp table in a stored procedure&#160; reduced the chance to reuse the execution plan. Change the temp table to temp variable 

 select top 1000  LimitedProgramTBNEventID into #Events from LimitedProgramTBNEvent(NOLOCK)  	where eventStatus = 7 
we changed it as follows:
 DECLARE @Events table (LimitedProgramTBNEventID int NOT NULL) insert into @Events [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=117&subd=sarosh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>We know that using Temp table in a stored procedure&#160; reduced the chance to reuse the execution plan. Change the temp table to temp variable </p>
<p>
<pre class="brush: sql;"> select top 1000  LimitedProgramTBNEventID into #Events from LimitedProgramTBNEvent(NOLOCK)  	where eventStatus = 7 </pre>
<p>we changed it as follows:</p>
<pre class="brush: sql;"> DECLARE @Events table (LimitedProgramTBNEventID int NOT NULL) insert into @Events select top 1000 LimitedProgramTBNEventID 	from LimitedProgramTBNEvent (NOLOCK)where eventStatus = 7  </pre>
<p>Here is another reason for not to use the Temp table. If you have a temp table then you cannot use the ‘Display Estimated execution plan&quot;’ option in the query analyzer. When a query is run using the &quot;Display Estimated Execution Plan&quot; option, it does not really run so no temp tables are created. Since they are not created, any references to them in the code will fail, which prevents an estimated execution plan from being created.&#160; </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarosh.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarosh.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarosh.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarosh.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarosh.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarosh.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarosh.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarosh.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarosh.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarosh.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=117&subd=sarosh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://sarosh.wordpress.com/2009/09/16/temp-table-variable-vs-temp-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8e93bef927d029c824b91da0b59f703?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">rsarosh</media:title>
		</media:content>
	</item>
		<item>
		<title>Not for replication</title>
		<link>http://sarosh.wordpress.com/2009/08/24/not-for-replication/</link>
		<comments>http://sarosh.wordpress.com/2009/08/24/not-for-replication/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 21:41:15 +0000</pubDate>
		<dc:creator>Rafat Sarosh</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://sarosh.wordpress.com/?p=90</guid>
		<description><![CDATA[If you have a database which is replicated, then run the following query on the publisher and if you get any result back then you got some work at your hand

select distinct t.[name], c.* from sys.tables t
    join sys.columns c on t.object_id = c.object_id
             and c.is_identity = 1 and c.is_replicated = 0

this query basically tells [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=90&subd=sarosh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>If you have a database which is replicated, then run the following query on the publisher and if you get any result back then you got some work at your hand</p>
<pre class="brush: sql;">
select distinct t.[name], c.* from sys.tables t
    join sys.columns c on t.object_id = c.object_id
             and c.is_identity = 1 and c.is_replicated = 0
</pre>
<p>this query basically tells that you have tables which have identity columns but they are not created with ‘NOT FOR REPLICATION’ option.</p>
<p>If that is the case then your identity columns are out of synch between publisher and subscriber. You can fix it by setting the is_replicated column to 1.</p>
<pre class="brush: sql;">
EXEC %%
ColumnEx(
ObjectID = @
object_id,
Name = @
identity_column).
SetIdentityNotForRepl(VALUE = 1)
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarosh.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarosh.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarosh.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarosh.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarosh.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarosh.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarosh.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarosh.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarosh.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarosh.wordpress.com/90/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=90&subd=sarosh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://sarosh.wordpress.com/2009/08/24/not-for-replication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8e93bef927d029c824b91da0b59f703?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">rsarosh</media:title>
		</media:content>
	</item>
		<item>
		<title>ACCESS (MDB) to XML with LINQ</title>
		<link>http://sarosh.wordpress.com/2009/06/17/access-mdb-to-xml-with-linq/</link>
		<comments>http://sarosh.wordpress.com/2009/06/17/access-mdb-to-xml-with-linq/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 00:30:59 +0000</pubDate>
		<dc:creator>Rafat Sarosh</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[MDB]]></category>
		<category><![CDATA[MS ACCESS]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://sarosh.wordpress.com/?p=79</guid>
		<description><![CDATA[I had some data in Access DB and wanted to convert it to XML. Data in Access was in one table called ‘Words’, with the following columns: Word, Meaning, Synonyms, Antonyms, Example etc.  I wanted to convert this data in XML as follows:

&#60;Dictionary&#62;
&#60;Word Spelling=&#34;Munificent&#34;&#62;
    &#60;Meaning&#62;very generous&#60;/Meaning&#62;
    &#60;Synonyms /&#62;
 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=79&subd=sarosh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I had some data in Access DB and wanted to convert it to XML. Data in Access was in one table called ‘Words’, with the following columns: Word, Meaning, Synonyms, Antonyms, Example etc.  I wanted to convert this data in XML as follows:</p>
<pre class="brush: csharp;">
&lt;Dictionary&gt;
&lt;Word Spelling=&quot;Munificent&quot;&gt;
    &lt;Meaning&gt;very generous&lt;/Meaning&gt;
    &lt;Synonyms /&gt;
    &lt;Antonyms /&gt;
    &lt;Example /&gt;
  &lt;/Word&gt;
  &lt;Word Spelling=&quot;Anfractuosity&quot;&gt;
    &lt;Meaning&gt;Twist or turn, A complicated or involved process. &lt;/Meaning&gt;
    &lt;Synonyms /&gt;
    &lt;Antonyms /&gt;
    &lt;Example&gt; The anfractuosities of his intellect and temper. –Macaulay &lt;/Example&gt;
  &lt;/Word&gt;
&lt;/Dictionary&gt;
</pre>
<p>LINQ made job to read the data and convert it to XML very easy, as you can see all this happen in one line.</p>
<pre class="brush: csharp;">
using System;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Xml.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace Convert2XML
{
    class Program
    {
static void Main(string[] args)
        {
                  string ConnectionString = @&quot;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Vocabulary.mdb;Persist Security Info=false&quot;;
                  DataContext db = new DataContext(new OleDbConnection(ConnectionString)) ;
                  Table &lt;words&gt; tblwords =   db.GetTable&lt;words&gt;();
                  System.IO.File.WriteAllText(&quot;Data.XML&quot;,
                            ( new XElement(&quot;Dictionary&quot;, from w in tblwords
                                                   select new XElement(&quot;Word&quot; ,
                                                          new XAttribute(&quot;Spelling&quot;, w.Word),
                                                   new XElement(&quot;Meaning&quot;, w.Meaning),
                                                   new XElement(&quot;Synonyms&quot;, w.Synonyms),
                                                   new XElement(&quot;Antonyms&quot;, w.Antonyms),
                                                   new XElement(&quot;Example&quot;, w.Example)
                                                   )
                                           )
                             ).ToString()
                             , Encoding.UTF8);
        }

        [Table(Name = &quot;words&quot;)]
        public class words
        {
            [Column]
            public string Word;
            [Column]
            public string Meaning;
            [Column]
            public string Synonyms;
            [Column]
            public string Antonyms;
            [Column]
            public int weight;
            [Column]
            public string Reference;
            [Column]
            public string Example;
            [Column]
            public string link;
        }
    }
}
</pre>
<p>If you don’t have OLEDB 12.0 then You can use the following connection string too</p>
<p>string ConnectionString = @&#8221;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Vocabulary.mdb;Persist Security Info=True&#8221; ;</p>
<p>If you don’t have Microsoft.ACE.OLEDB.12.0 then get it from here</p>
<p>http://www.microsoft.com/downloads/details.aspx?familyid=7554F536-8C28-4598-9B72-EF94E038C891&amp;displaylang=en</p>
<p>These oledb providers are 32 bit, so make sure to compile your project for 32 bit on a 64 bit machine.<br />
<em>Error handling and comments are removed for the brevity.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarosh.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarosh.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarosh.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarosh.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarosh.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarosh.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarosh.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarosh.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarosh.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarosh.wordpress.com/79/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=79&subd=sarosh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://sarosh.wordpress.com/2009/06/17/access-mdb-to-xml-with-linq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8e93bef927d029c824b91da0b59f703?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">rsarosh</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Partition Cube – using C#</title>
		<link>http://sarosh.wordpress.com/2009/06/03/how-to-partition-cube-%e2%80%93-using-c/</link>
		<comments>http://sarosh.wordpress.com/2009/06/03/how-to-partition-cube-%e2%80%93-using-c/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 23:39:05 +0000</pubDate>
		<dc:creator>Rafat Sarosh</dc:creator>
				<category><![CDATA[Analysis Server]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Cube]]></category>
		<category><![CDATA[Cube Partition]]></category>
		<category><![CDATA[SQL Analysis Server]]></category>

		<guid isPermaLink="false">http://sarosh.wordpress.com/2009/06/03/how-to-partition-cube-%e2%80%93-using-c/</guid>
		<description><![CDATA[There are many different ways you can partition a cube. Here I am talking about &#8211; how you can use C# to partition a cube from a DTS package?
Using  Microsoft.AnalysisServices  Object API, you can travel the whole Hierarchy of objects  and completely administer an Analysis Service Instance. From the connection Object you can get to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=53&subd=sarosh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>There are many different ways you can partition a cube. Here I am talking about &#8211; how you can use C# to partition a cube from a DTS package?</p>
<p>Using  Microsoft.AnalysisServices  Object API, you can travel the whole Hierarchy of objects  and completely administer an Analysis Service Instance. From the connection Object you can get to the Server and database instances. And in database you can transverse the Cube and their different measures. Once you get hold of a measure then you can transverse the different partitions of measures and dig deep in to each partition query definitions etc.<br />
<span id="more-53"></span><br />
To keep things simple, there is one prerequisite to name your measure partitions in the in following format: MeasureName_DateSKey. DateSKey is a long number showing the date from 1<sup>st</sup> Jan 1990. To get the DateSKey for a date you can use the following formula:</p>
<p> DateTime d;<br />
d.Date.Subtract(new System.DateTime(1900, 1, 1, 0, 0, 0)).Days</p>
<p>So, if your measure name is ‘Distinct Downloaders Daily’ then it may have following partitions for every 7 days as follows: Distinct Downloaders Daily_39812, Distinct Downloaders Daily_398129… etc<br />
<img src="http://sarosh.files.wordpress.com/2009/06/cubeparition.jpg?w=433&#038;h=280" alt="CubeParition" title="CubeParition" width="433" height="280" class="alignnone size-full wp-image-77" /><br />
Open a new DTS package, drag the script component and double click to start editing a C# script.</p>
<p>Include the following library:</p>
<pre class="brush: csharp;">
using Microsoft.AnalysisServices;
using System.Collections.ObjectModel;
</pre>
<p>Define a new structure as measure, to hold the definition of your measures and there partition boundaries.</p>
<p> 
<pre class="brush: csharp;">
// Structure used to keep the Measure name and their partition durations
struct Measure
{
       public string MeasureName;
      // Partition duration in days
      public int iPartitionDays;
      public Measure(string measureName, int ipartitionDays)
        {
          MeasureName = measureName;
          iPartitionDays = ipartitionDays;
        }
}
</pre>
<p>Now define a collection of measures which you want to partition. Sure, this information you can get from a Config file too … It is hardcoded in code for the illustration purpose.</p>
<pre class="brush: csharp;">
Collection Measures = new Collection();
Measures.Add(new Measure(&quot;DownLoad Summary&quot;, 7));
Measures.Add(new Measure(&quot;Distinct Downloaders Daily&quot;, 7));
Measures.Add(new Measure(&quot;Distinct Downloaders Weekly&quot;, 30));
Measures.Add(new Measure(&quot;Top Referer&quot;, 30));
</pre>
<p>Now you can use this collection to call a method called ProcessCube. Here is the code, removed all the error handling for the sake of brevity.</p>
<pre class="brush: csharp;">
private void ProcessCube( Collection Measures, string cubeName)
{
Server oServer = new Server();
try
{
// Get Connection object and then get the Server and Database name from DTS connection object
ConnectionManager oConnection = null;
for (int i = 0; i &amp;lt; Dts.Connections.Count; i++)
{
oConnection = Dts.Connections[i];
if (oConnection.Name == &quot;CubeConnectionName&quot;) //Connection name as defined in ETL package
{
break;
}
else
oConnection = null;
}

string sServer = (string)(oConnection.Properties[&quot;ServerName&quot;].GetValue(oConnection));
string sDatabase = (string)(oConnection.Properties[&quot;InitialCatalog&quot;].GetValue(oConnection));
oServer.Connect(sServer);// connect to the server and start scanning down the object hierarchy
Database oDB = oServer.Databases.FindByName(sDatabase);
Cube oCube = oDB.Cubes.FindByName(cubeName);
foreach (Measure m in Measures)
{
CreatePartition(oCube, m.MeasureName, m.iPartitionDays); //Create old paritions
DeletePartitions(oCube, m.MeasureName, m.iPartitionDays); // Delete old partitions

}
}
finally
{
if (oServer.Connected)
oServer.Disconnect();
}
}

///
/// Create a new partition based on the skipdays
///
/// Cube Name to be processed
/// MeasureName which need to be partitioned
/// Partition duration e.g. for daily=1, weekly=7, Monthly =30
/// true on success
///
///
/// This code Creates the new partition names, using the default Measure name as the partition name and the
/// DateSKey. for e.g. if the measure name is Browser and the DateSKey=39241
/// then the partition name will be 'Browser_39241'
///
///
///

bool CreatePartition(Cube oCube, string measureName, int iDaysToSkip)
{
Byte[] dataBytes = new Byte[5000];
QueryBinding oQueryBinding;
bool bflag = false;
int iCurrentDateSKey = (int)Dts.Variables[&quot;CubeCurrentDateSKey&quot;].Value; //Get the currentDateSkey
MeasureGroup oMeasureGroup = oCube.MeasureGroups.FindByName(measureName); // Find all measure groups
if (oMeasureGroup == null) return false;
Partition oPartition = oMeasureGroup.Partitions[oMeasureGroup.Partitions.Count - 1]; //Get the Last partition
int LastCubeDateSkey = GetPartitionDateSKey(oPartition);//Get the lastkey DateSkey
string DefaultPartitionName = oMeasureGroup.Name; //Get the Partition name first part
string sNewPartitionName = string .Empty ;
if (LastCubeDateSkey == 1) //if it is first default partition
{
sNewPartitionName = DefaultPartitionName + &quot;_&quot; + iCurrentDateSKey; //Making the new partition Name
}
else
{
if (LastCubeDateSkey + iDaysToSkip &amp;lt;= iCurrentDateSKey)
sNewPartitionName = DefaultPartitionName + &quot;_&quot; + iCurrentDateSKey;
else
return true; //No need to create the partition yet. Every thing is fine, go back
}

//Just another check, if the partition already existing then skip
oPartition = oMeasureGroup.Partitions.FindByName(sNewPartitionName);
Partition oPartitionNew;
if (oPartition == null)
{
//Did not get the partition, lets create one,Get the last partition
oPartition = oMeasureGroup.Partitions[oMeasureGroup.Partitions.Count - 1];
//Clone the properties from the last partition to the new partition.
oPartitionNew = oPartition.Clone();
oPartitionNew.ID = sNewPartitionName;
oPartitionNew.Name = sNewPartitionName;
oQueryBinding = oPartitionNew.Source as QueryBinding;
if (oQueryBinding == null)
{
return true; // No Query, No Partition
}
oQueryBinding.QueryDefinition = GetNewQuery(oQueryBinding.QueryDefinition, iCurrentDateSKey, iDaysToSkip);
if (oQueryBinding.QueryDefinition == null || oQueryBinding.QueryDefinition == string.Empty)
{
Dts.Log(&quot;Partition : &quot; + oPartitionNew.Name + &quot; Empty Query returned&quot;, 0, dataBytes);
Dts.Events.FireInformation(0, &quot;CreatePartition&quot;, &quot;Partition : &quot; + oPartitionNew.Name + &quot; Empty Query returned&quot;, null, 0, ref bflag);
return false;
}

if (oMeasureGroup.Partitions.Contains(oPartitionNew))
{
Dts.Log(&quot;Partition : &quot; + oPartitionNew.Name + &quot; Already exists.&quot;, 0, dataBytes);
return true; //Oh! what a surprise, this partition already existing.
}
oMeasureGroup.Partitions.Add(oPartitionNew);
try
{
oPartitionNew.Update();
Dts.Log(&quot;Partition updated: &quot; + oPartitionNew.Name, 0, dataBytes);
Dts.Events.FireInformation(0, &quot;CreatePartition&quot;, &quot;Partition updated: &quot; + oPartitionNew.Name, null, 0, ref bflag);
oPartitionNew.Process(ProcessType.ProcessFull);
Dts.Log(&quot;Partition Processed: &quot; + oPartitionNew.Name, 0, dataBytes);
Dts.Events.FireInformation(0, &quot;CreatePartition&quot;, &quot;Partition Processed: &quot; + oPartitionNew.Name, null, 0, ref bflag);

}
catch (Exception e)
{
if (oPartitionNew != null)
Dts.Log(&quot;Error in Create partition: &quot; + oPartitionNew.Name + &quot;Exception: &quot; + e.Message, 0, dataBytes);
else
Dts.Log(&quot;Error in Create partition: Unknown. Exception: &quot; + e.Message, 0, dataBytes);
return false;
}
}
return true;
} //~Create partitio ends here

///
/// This function Gets the partition DateSKey from the partition name
///
/// On Success the right DateSKey, on error zero
///
private int GetPartitionDateSKey(Partition oPartition)
{
if (oPartition == null) return 0;
try
{
return Convert.ToInt32(oPartition.Name.Substring(oPartition.Name.LastIndexOf(&quot;_&quot;) + 1));
}
catch (Exception ex)
{
return 0;
}
}

///
/// Get the new Query for the partition.
///

string GetNewQuery(string sourceQuery, int iCurrentDateSKey, int iDaysToSkip)
{

string mainQuery = string.Empty;
string newQuery = string.Empty;
string newCondition;
//From the Query get the Where clause
int LastIndex = sourceQuery.ToUpper().LastIndexOf(&quot;WHERE&quot;) ;
if (LastIndex &amp;gt; 0)
{
mainQuery = sourceQuery.Substring(0, LastIndex);
newCondition = &quot; [DateSKey] &amp;gt;= &quot; + Convert.ToString(iCurrentDateSKey) + &quot; AND [DateSKey] = &quot; + Convert.ToString(iCurrentDateSKey) + &quot; AND [DateSKey] &amp;lt; &quot; + Convert.ToString(iCurrentDateSKey + iDaysToSkip ) + &quot; &quot;;
newQuery = sourceQuery + &quot; WHERE &quot; + newCondition;
}

return newQuery;
}

//Deletes old partitions based on the data retention period.
bool DeletePartitions(Cube oCube, string measureName, int iDaysToSkip)
{
Collection PartitionTobeDeleted = new Collection();
int iDateSkeyTobeDeleted ;
Byte [] dataBytes = new Byte [5000];
bool bflag = false;
// 13 * 30 = 390 days - 13 months
int iDaysTobeDeleted = 390 ; //TODO: Get from a variable [&quot;DataRetentionPeriodInDays&quot;]

//Getting the number for which partition needs to deleted. old partitions
iDateSkeyTobeDeleted = GetDateSKey (DateTime.Now) - iDaysTobeDeleted ;

MeasureGroup oMeasureGroup = oCube.MeasureGroups.FindByName (measureName);
if (oMeasureGroup == null)
{
Dts.Log(&quot;Measure : &quot; + oMeasureGroup.Name + &quot; not found.&quot;, 0, dataBytes);
return false;
}
Dts.Log(&quot;[DeletePartitions] Working on Measure: &quot; + oMeasureGroup.Name, 0, dataBytes);
string sPartitionName = string.Empty; //used for logging the correct PartitionName
int MaxPartitions = oMeasureGroup.Partitions.Count;
foreach (Partition oPartition2 in oMeasureGroup.Partitions)
{
sPartitionName = oPartition2.Name;
if (!oPartition2.Name.Contains(&quot;_&quot;))
continue; //_ is not there it means it is not the partition which we need to delete
try
{
// Get the boundary partition date from partition name
int spartitionBoundaryDateSkey = GetPartitionDateSKey(oPartition2);
if (spartitionBoundaryDateSkey == 0) continue;

//if partition DateSKey is smaller then the partition to be deleted then delete
//MaxPartition protects us from deleting all the partitions from the measures
if (spartitionBoundaryDateSkey 1)
{
MaxPartitions--;
//can not drop object here because of foreach.
PartitionTobeDeleted.Add(oPartition2);
#region Log
Dts.Log(&quot;Found partition that needs to be dropped: &quot; + oPartition2.Name, 0, dataBytes);
Dts.Events.FireInformation(0, &quot;DeletePartition&quot;, &quot;Found partition that needs to be dropped: &quot; + oPartition2.Name, null, 0, ref bflag);
#endregion
}
}
catch (Exception e)
{
Dts.Log(&quot;Error in Delete partition: &quot; + sPartitionName + &quot;Exception: &quot; + e.Message, 0, dataBytes);
Dts.Events.FireInformation(0, &quot;DeletePartition&quot;, &quot;Error in Delete partition: &quot; + sPartitionName + &quot;Exception: &quot; + e.Message, null, 0, ref bflag);
}
}
//Deleting partition from the measure group
foreach (Partition oPartition in PartitionTobeDeleted)
{
XmlaWarningCollection warningColln = new XmlaWarningCollection();
oPartition.Drop(DropOptions.Default, warningColln);
}
return true;
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarosh.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarosh.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarosh.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarosh.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarosh.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarosh.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarosh.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarosh.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarosh.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarosh.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=53&subd=sarosh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://sarosh.wordpress.com/2009/06/03/how-to-partition-cube-%e2%80%93-using-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8e93bef927d029c824b91da0b59f703?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">rsarosh</media:title>
		</media:content>

		<media:content url="http://sarosh.files.wordpress.com/2009/06/cubeparition.jpg" medium="image">
			<media:title type="html">CubeParition</media:title>
		</media:content>
	</item>
		<item>
		<title>Push or Pull Replication</title>
		<link>http://sarosh.wordpress.com/2009/03/11/push-or-pull-replication/</link>
		<comments>http://sarosh.wordpress.com/2009/03/11/push-or-pull-replication/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 14:18:55 +0000</pubDate>
		<dc:creator>Rafat Sarosh</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://sarosh.wordpress.com/?p=47</guid>
		<description><![CDATA[A study conducted by MSCOM ops team found 1 GB of data took 110 Minute to push and 12.5 minutes to Pull across the continents. Furthermore SQL 2008 with Windows Server 2008 made a huge difference over SQL 2005 and Windows Server 2003. 
 
Push subscription replication of character data with SQL Server 2008 running on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=47&subd=sarosh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0;"><span style="color:black;"><span style="font-size:small;"><span style="font-family:Calibri;">A study conducted by MSCOM ops team found 1 GB of data took 110 Minute to push and 12.5 minutes to Pull across the continents. Furthermore SQL 2008 with Windows Server 2008 made a huge difference over SQL 2005 and Windows Server 2003. </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="color:black;"><span style="font-family:Calibri;font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="color:black;"><span style="font-size:small;"><span style="font-family:Calibri;">Push subscription replication of character data with SQL Server 2008 running on Windows Server 2008 yielded a 104 percent increase over SQL Server 2005 running on Windows Server 2003, and pull subscription replication of the same data yielded a 1,298 percent gain.</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="color:black;"><span style="font-family:Calibri;font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="color:black;"><span style="font-size:small;"><span style="font-family:Calibri;">Lot of performance improvement is attributed to windows server TCP/IP Stack and SQL Native Client driver. Different reader and writer thread behavior resulted in push and pull performance difference. </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="color:black;"><span style="font-size:small;"></span></span> </p>
<p class="MsoNormal" style="margin:0;"><span style="color:black;"><span style="font-size:small;"><span style="font-family:Calibri;">Reader thread fills two buffers <span> </span>of 40 KB <span> </span>and signals the Writer thread to write the buffer on subscriber, so the 40 KB packet moves thru and fro over the wire, but in case of Pull model Writer thread pulls the data in one huge chunk as big as TCP/IP let it get.<span>  </span>One of the most significant improvements to Windows Server 2008 is the autotuning of the receive window size, designed for high-latency environments. In previous versions of the operating system, the maximum window size was limited by the 16-bit Window field in the TCP header amounting to a maximum window size of 64 KB. In Windows Server 2008, by combining the Window field together with a Scale Factor field of the TCP header, the window can be scaled or tuned, up to 16 megabytes (MB) in size.</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="color:black;"><span style="font-family:Calibri;font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Calibri;font-size:small;">Read the full study here </span><a href="http://msdn.microsoft.com/en-us/library/dd263442.aspx"><span style="font-family:Calibri;font-size:small;">http://msdn.microsoft.com/en-us/library/dd263442.aspx</span></a></p>
<p class="MsoNormal" style="margin:0;"> </p>
<p class="MsoNormal" style="margin:0;"> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarosh.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarosh.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarosh.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarosh.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarosh.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarosh.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarosh.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarosh.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarosh.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarosh.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarosh.wordpress.com&blog=1119187&post=47&subd=sarosh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://sarosh.wordpress.com/2009/03/11/push-or-pull-replication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8e93bef927d029c824b91da0b59f703?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">rsarosh</media:title>
		</media:content>
	</item>
	</channel>
</rss>