<?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: Saving large numbers of entities in LightSpeed</title>
	<atom:link href="http://www.mindscapehq.com/blog/index.php/2008/09/18/saving-large-numbers-of-entities-in-lightspeed/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mindscapehq.com/blog/index.php/2008/09/18/saving-large-numbers-of-entities-in-lightspeed/</link>
	<description>The official blog of Mindscape</description>
	<lastBuildDate>Wed, 08 Feb 2012 09:29:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Ivan Towlson</title>
		<link>http://www.mindscapehq.com/blog/index.php/2008/09/18/saving-large-numbers-of-entities-in-lightspeed/comment-page-1/#comment-35251</link>
		<dc:creator>Ivan Towlson</dc:creator>
		<pubDate>Sun, 18 Oct 2009 20:18:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.mindscape.co.nz/blog/?p=262#comment-35251</guid>
		<description>Yes, you can change the LightSpeedContext.IdentityBlockSize in code over the course of an application.  When LightSpeed needs some more IDs, it will increment the KeyTable by the current IdentityBlockSize.  LightSpeed will continue using IDs from the last allocated block until they run out, so if you overallocate and then step back down to 1, you won&#039;t incur a new query until the overallocated block is exhausted.  Thus:

uow.Context.IdentityBlockSize = 1;
uow.Add(entity1);  // increments KeyTable by 1
uow.Add(entity2);  // block of 1 has run out, so increment again by 1
uow.Context.IdentityBlockSize = 10;
uow.Add(entity3);  // block of 1 has run out, increment by 10
uow.Add(entity4);  // still enough left in block of 10, so KeyTable not updated
uow.Context.IdentityBlockSize = 1;
uow.Add(entity5);  // still enough left in block of 10, so KeyTable not updated

Finally, don&#039;t get hung up on micro-optimising this stuff.  There&#039;s no real penalty for having gaps in your IDs, unless it&#039;s going to result in you having to use an Int64 ID instead of an Int32, and even then the penalty is insignificant.  Make sure you balance optimisation against keeping the code simple!</description>
		<content:encoded><![CDATA[<p>Yes, you can change the LightSpeedContext.IdentityBlockSize in code over the course of an application.  When LightSpeed needs some more IDs, it will increment the KeyTable by the current IdentityBlockSize.  LightSpeed will continue using IDs from the last allocated block until they run out, so if you overallocate and then step back down to 1, you won&#8217;t incur a new query until the overallocated block is exhausted.  Thus:</p>
<p>uow.Context.IdentityBlockSize = 1;<br />
uow.Add(entity1);  // increments KeyTable by 1<br />
uow.Add(entity2);  // block of 1 has run out, so increment again by 1<br />
uow.Context.IdentityBlockSize = 10;<br />
uow.Add(entity3);  // block of 1 has run out, increment by 10<br />
uow.Add(entity4);  // still enough left in block of 10, so KeyTable not updated<br />
uow.Context.IdentityBlockSize = 1;<br />
uow.Add(entity5);  // still enough left in block of 10, so KeyTable not updated</p>
<p>Finally, don&#8217;t get hung up on micro-optimising this stuff.  There&#8217;s no real penalty for having gaps in your IDs, unless it&#8217;s going to result in you having to use an Int64 ID instead of an Int32, and even then the penalty is insignificant.  Make sure you balance optimisation against keeping the code simple!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francesco</title>
		<link>http://www.mindscapehq.com/blog/index.php/2008/09/18/saving-large-numbers-of-entities-in-lightspeed/comment-page-1/#comment-35203</link>
		<dc:creator>Francesco</dc:creator>
		<pubDate>Fri, 16 Oct 2009 07:04:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.mindscape.co.nz/blog/?p=262#comment-35203</guid>
		<description>Hi Ivan,
I&#039;m just starting with LightSpeed, but I&#039;m really intered in the discussion about &quot;Identity Size&quot; using the Key Table... My question is: is it possible to change dinamically the IdentityBlockSize from code. In this way the base IdentityBlockSize could be setted to low size (maybe 1 for the base) and, then, when needed (when i have to insert a huge number of records) can be setted to a greater value.
Thanks in advance for your suggestions. Francesco</description>
		<content:encoded><![CDATA[<p>Hi Ivan,<br />
I&#8217;m just starting with LightSpeed, but I&#8217;m really intered in the discussion about &#8220;Identity Size&#8221; using the Key Table&#8230; My question is: is it possible to change dinamically the IdentityBlockSize from code. In this way the base IdentityBlockSize could be setted to low size (maybe 1 for the base) and, then, when needed (when i have to insert a huge number of records) can be setted to a greater value.<br />
Thanks in advance for your suggestions. Francesco</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Peters</title>
		<link>http://www.mindscapehq.com/blog/index.php/2008/09/18/saving-large-numbers-of-entities-in-lightspeed/comment-page-1/#comment-23174</link>
		<dc:creator>Andrew Peters</dc:creator>
		<pubDate>Fri, 19 Sep 2008 01:07:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.mindscape.co.nz/blog/?p=262#comment-23174</guid>
		<description>&quot;...That means two database round-trips for every entity.&quot;

Usually, this is batched with the offending INSERT so only one round-trip.</description>
		<content:encoded><![CDATA[<p>&#8220;&#8230;That means two database round-trips for every entity.&#8221;</p>
<p>Usually, this is batched with the offending INSERT so only one round-trip.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic (Requested URI is rejected)
Database Caching 1/12 queries in 0.010 seconds using disk: basic
Content Delivery Network via cdn.mindscapehq.com

Served from: www.mindscapehq.com @ 2012-02-08 16:36:27 -->
