<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Build Your Own Data Access Layer: Enabling Bulk Inserts</title>
	<atom:link href="http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/feed/" rel="self" type="application/rss+xml" />
	<link>http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/</link>
	<description>Trying to walk that thin line between intelligence and ignorance</description>
	<lastBuildDate>Wed, 17 Mar 2010 18:22:17 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/comment-page-1/#comment-22718</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Thu, 15 Oct 2009 12:09:02 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=1733#comment-22718</guid>
		<description>Sorry, haven&#039;t really had the time to look into this</description>
		<content:encoded><![CDATA[<p>Sorry, haven&#8217;t really had the time to look into this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/comment-page-1/#comment-22715</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Thu, 15 Oct 2009 11:25:03 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=1733#comment-22715</guid>
		<description>Any thoughts in regards to fetching strategys?</description>
		<content:encoded><![CDATA[<p>Any thoughts in regards to fetching strategys?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/comment-page-1/#comment-22708</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Tue, 13 Oct 2009 14:02:15 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=1733#comment-22708</guid>
		<description>I assume you would just call something similar to .net tiers...?

Fetch(entity or collection, levels, types to include, types to exclude)

Fetch(fixtures, 1, typeof(Team), typeof(Venue))... you just call this in your service layer and default to lazy loading otherwise.. or define something on the domain entity to say what to types to get by default? I would be using ActiveRecord under the service layer.

While this isn&#039;t one trip it would still be less than several 100 potential

public class Fixture
{
   // This would be ignored as the deeploading options excldues this
   [DeepLoad]
   public Venue Venue
   {
     return this.venue;
   }

   [DeepLoad]
   public Team HomeTeam
   {
    get 
    {
       return this.homeTeam;
     }
   }

   [DeepLoad]
   public Team AwayTeam
   {
    get 
    {
       return this.awayTeam;
     }    
   }
}</description>
		<content:encoded><![CDATA[<p>I assume you would just call something similar to .net tiers&#8230;?</p>
<p>Fetch(entity or collection, levels, types to include, types to exclude)</p>
<p>Fetch(fixtures, 1, typeof(Team), typeof(Venue))&#8230; you just call this in your service layer and default to lazy loading otherwise.. or define something on the domain entity to say what to types to get by default? I would be using ActiveRecord under the service layer.</p>
<p>While this isn&#8217;t one trip it would still be less than several 100 potential</p>
<p>public class Fixture<br />
{<br />
   // This would be ignored as the deeploading options excldues this<br />
   [DeepLoad]<br />
   public Venue Venue<br />
   {<br />
     return this.venue;<br />
   }</p>
<p>   [DeepLoad]<br />
   public Team HomeTeam<br />
   {<br />
    get<br />
    {<br />
       return this.homeTeam;<br />
     }<br />
   }</p>
<p>   [DeepLoad]<br />
   public Team AwayTeam<br />
   {<br />
    get<br />
    {<br />
       return this.awayTeam;<br />
     }<br />
   }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/comment-page-1/#comment-22707</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Tue, 13 Oct 2009 13:13:49 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=1733#comment-22707</guid>
		<description>advice... umm, can you get a new job? :p

the fetching strategy is going to take the most effort out of the 3 options, but it gives you the flexibility to optimize for each specific scenario that you encounter</description>
		<content:encoded><![CDATA[<p>advice&#8230; umm, can you get a new job? :p</p>
<p>the fetching strategy is going to take the most effort out of the 3 options, but it gives you the flexibility to optimize for each specific scenario that you encounter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/comment-page-1/#comment-22706</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Tue, 13 Oct 2009 12:55:02 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=1733#comment-22706</guid>
		<description>Sorry when I say &quot;for all entities&quot; i mean for anything using the framework so like a default way of getting things from the DB</description>
		<content:encoded><![CDATA[<p>Sorry when I say &#8220;for all entities&#8221; i mean for anything using the framework so like a default way of getting things from the DB</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/comment-page-1/#comment-22705</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Tue, 13 Oct 2009 12:53:45 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=1733#comment-22705</guid>
		<description>So really you need some sort of fetching strategy (not sure how you would implement)? because as always.. &#039;it depends&#039;..

My example query:

Fixture (say 100 of them)
Fixture.HomeTeam (type Team), Fixture.AwayTeam (type Team)

Stored procedures would be as its for an ORM ... FixtureListAll, FixtureGetByID, TeamGetByID

Options I can see are either:

1.

FixtureList

and then work out what unique TeamIDs there is and then do a batch call on 
TeamGetByID

So 2 trips to DB

OR

2.

FixtureList and deep load 1 lot of children underneath, so bring back the Teams also, but this would be for all entities so performance would be hit and miss

So 1 trip to DB but bring back more than you need
OR

3.

A fetching strategy and you create a single stored procedure like option 2 but only when you need it, so default to lazy load or something

So 1 trip but because you programmed for this you are aware of what your bringing back

Any advice/suggestions welcome</description>
		<content:encoded><![CDATA[<p>So really you need some sort of fetching strategy (not sure how you would implement)? because as always.. &#8216;it depends&#8217;..</p>
<p>My example query:</p>
<p>Fixture (say 100 of them)<br />
Fixture.HomeTeam (type Team), Fixture.AwayTeam (type Team)</p>
<p>Stored procedures would be as its for an ORM &#8230; FixtureListAll, FixtureGetByID, TeamGetByID</p>
<p>Options I can see are either:</p>
<p>1.</p>
<p>FixtureList</p>
<p>and then work out what unique TeamIDs there is and then do a batch call on<br />
TeamGetByID</p>
<p>So 2 trips to DB</p>
<p>OR</p>
<p>2.</p>
<p>FixtureList and deep load 1 lot of children underneath, so bring back the Teams also, but this would be for all entities so performance would be hit and miss</p>
<p>So 1 trip to DB but bring back more than you need<br />
OR</p>
<p>3.</p>
<p>A fetching strategy and you create a single stored procedure like option 2 but only when you need it, so default to lazy load or something</p>
<p>So 1 trip but because you programmed for this you are aware of what your bringing back</p>
<p>Any advice/suggestions welcome</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/comment-page-1/#comment-22704</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Tue, 13 Oct 2009 09:40:16 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=1733#comment-22704</guid>
		<description>@Tom

depends on the dataset in the referenced table... if it&#039;s more likely that the number of needed records is somewhat similar to the number of records in the referring table then i&#039;d just join the two in one query

if the number of needed records in the referenced table will be much smaller than the number of records in the referring table, i&#039;d go for two statements and try to bring back only the ones i really need in the second statement.  your stored procedure could then still send back both resultsets... with a datareader you can process each resultset returned by a statement so that wouldn&#039;t be an issue

either way you do it, as long as you combine both operations in one stored procedure then you don&#039;t really need to worry about the &#039;overhead&#039; of a second query since you&#039;re not really paying for the network latency of multiple remote calls</description>
		<content:encoded><![CDATA[<p>@Tom</p>
<p>depends on the dataset in the referenced table&#8230; if it&#8217;s more likely that the number of needed records is somewhat similar to the number of records in the referring table then i&#8217;d just join the two in one query</p>
<p>if the number of needed records in the referenced table will be much smaller than the number of records in the referring table, i&#8217;d go for two statements and try to bring back only the ones i really need in the second statement.  your stored procedure could then still send back both resultsets&#8230; with a datareader you can process each resultset returned by a statement so that wouldn&#8217;t be an issue</p>
<p>either way you do it, as long as you combine both operations in one stored procedure then you don&#8217;t really need to worry about the &#8216;overhead&#8217; of a second query since you&#8217;re not really paying for the network latency of multiple remote calls</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/comment-page-1/#comment-22703</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Tue, 13 Oct 2009 09:26:04 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=1733#comment-22703</guid>
		<description>Some good posts.

What would you suggest in regards to deep loading and using stored procedures, say you have a list of 100 of something each having a foreign key to another table ... (using batch queries)

We have to use stored procedures at our place and I am looking at building our own basic ORM.

1. Get all of the list and the FK records
2. Get all of the list and attempt to get unique FK records (so you bring back less from DB).</description>
		<content:encoded><![CDATA[<p>Some good posts.</p>
<p>What would you suggest in regards to deep loading and using stored procedures, say you have a list of 100 of something each having a foreign key to another table &#8230; (using batch queries)</p>
<p>We have to use stored procedures at our place and I am looking at building our own basic ORM.</p>
<p>1. Get all of the list and the FK records<br />
2. Get all of the list and attempt to get unique FK records (so you bring back less from DB).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #453</title>
		<link>http://davybrion.com/blog/2009/10/build-your-own-data-access-layer-enabling-bulk-inserts/comment-page-1/#comment-22700</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #453</dc:creator>
		<pubDate>Tue, 13 Oct 2009 07:44:27 +0000</pubDate>
		<guid isPermaLink="false">http://davybrion.com/blog/?p=1733#comment-22700</guid>
		<description>[...] Build Your Own Data Access Layer: Enabling Bulk Inserts - Davy Brion resumes his series on creating his own ORM / Data Access Layer from scratch with a look at enabling his framework to support bulk inserts of data [...]</description>
		<content:encoded><![CDATA[<p>[...] Build Your Own Data Access Layer: Enabling Bulk Inserts &#8211; Davy Brion resumes his series on creating his own ORM / Data Access Layer from scratch with a look at enabling his framework to support bulk inserts of data [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
