 




<?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: Optimizing/Indexing to find last transaction</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/optimizingindexing-to-find-last-transaction/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/optimizingindexing-to-find-last-transaction/</link>
	<description></description>
	<lastBuildDate>Thu, 23 May 2013 13:24:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/optimizingindexing-to-find-last-transaction/#comment-72365</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Fri, 08 Jan 2010 06:04:01 +0000</pubDate>
		<guid isPermaLink="false">#comment-72365</guid>
		<description><![CDATA[&lt;i&gt;The transaction file that I’m reading is actually an indexed view that gives limited results...&lt;/i&gt;

Is that a hint that we haven&#039;t actually been told what the tables actually are? Are you saying that the original SELECT in the question is actually being processed over views rather than the real tables?

So, we need to work out the problems of too-slow performance without knowing what&#039;s really being queried...?

I don&#039;t see much hope.

Tom]]></description>
		<content:encoded><![CDATA[<p><i>The transaction file that I’m reading is actually an indexed view that gives limited results&#8230;</i></p>
<p>Is that a hint that we haven&#8217;t actually been told what the tables actually are? Are you saying that the original SELECT in the question is actually being processed over views rather than the real tables?</p>
<p>So, we need to work out the problems of too-slow performance without knowing what&#8217;s really being queried&#8230;?</p>
<p>I don&#8217;t see much hope.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: modmod</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/optimizingindexing-to-find-last-transaction/#comment-36517</link>
		<dc:creator>modmod</dc:creator>
		<pubDate>Thu, 12 Apr 2007 15:59:23 +0000</pubDate>
		<guid isPermaLink="false">#comment-36517</guid>
		<description><![CDATA[Unluckily the subquery actually takes longer in this situation.  The transaction file that I&#039;m reading is actually an indexed view that gives limited results, doing a subquery seems to cause the system to compile more of a list then it needs, whereas doing the left join saves time (for a specific 300 records, the left join takes 3 min, and the subquery takes 5 min)

]]></description>
		<content:encoded><![CDATA[<p>Unluckily the subquery actually takes longer in this situation.  The transaction file that I&#8217;m reading is actually an indexed view that gives limited results, doing a subquery seems to cause the system to compile more of a list then it needs, whereas doing the left join saves time (for a specific 300 records, the left join takes 3 min, and the subquery takes 5 min)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bigkat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/optimizingindexing-to-find-last-transaction/#comment-36518</link>
		<dc:creator>bigkat</dc:creator>
		<pubDate>Thu, 12 Apr 2007 15:13:56 +0000</pubDate>
		<guid isPermaLink="false">#comment-36518</guid>
		<description><![CDATA[assuming recdate and OH are in location file and are single values, and that the locations file is unique for loc, item, version.

try

with maxtrans as(SELECT item2, version2,
 max(TranDate) lasttran from transactions
group by item2, version2) 
SELECT loc, item, version, Rec_Date, OH,
 lasttran from locations left outer join 
maxtrans on Item=Item2 and Version=Version2]]></description>
		<content:encoded><![CDATA[<p>assuming recdate and OH are in location file and are single values, and that the locations file is unique for loc, item, version.</p>
<p>try</p>
<p>with maxtrans as(SELECT item2, version2,<br />
 max(TranDate) lasttran from transactions<br />
group by item2, version2)<br />
SELECT loc, item, version, Rec_Date, OH,<br />
 lasttran from locations left outer join<br />
maxtrans on Item=Item2 and Version=Version2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sheldonlinker</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/optimizingindexing-to-find-last-transaction/#comment-36519</link>
		<dc:creator>sheldonlinker</dc:creator>
		<pubDate>Wed, 04 Apr 2007 13:33:20 +0000</pubDate>
		<guid isPermaLink="false">#comment-36519</guid>
		<description><![CDATA[This is one of those rare circumstances where redundant data may be your best bet.  Consider writing records to a Last Transaction file, and reading from that later:

Do the main transaction, without commit
Update the appropriate last transaction record
If the number of records updated is zero
___Insert the appropriate last transaction record
Commit
---
Sheldon Linker (sol@linker.com)
Linker Systems, Inc. (www.linkersystems.com)
800-315-1174 (+1-949-552-1904)]]></description>
		<content:encoded><![CDATA[<p>This is one of those rare circumstances where redundant data may be your best bet.  Consider writing records to a Last Transaction file, and reading from that later:</p>
<p>Do the main transaction, without commit<br />
Update the appropriate last transaction record<br />
If the number of records updated is zero<br />
___Insert the appropriate last transaction record<br />
Commit<br />
&#8212;<br />
Sheldon Linker (sol@linker.com)<br />
Linker Systems, Inc. (www.linkersystems.com)<br />
800-315-1174 (+1-949-552-1904)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: modmod</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/optimizingindexing-to-find-last-transaction/#comment-36520</link>
		<dc:creator>modmod</dc:creator>
		<pubDate>Tue, 03 Apr 2007 13:34:20 +0000</pubDate>
		<guid isPermaLink="false">#comment-36520</guid>
		<description><![CDATA[I can&#039;t index LastTran, last tran is from the subselect which selects item, version, max(tran) I do have a logical that indexes item, version, tran, and I get acceptable results if I run the subquery by itself, (because strsql will retrieve blocks of rows instead of the whole resultset I believe)

the min(loc) was an artifact of me rewriting an anonymized, simplified version of what I&#039;m pulling back.  An item can be in more then one location, and the report is calling for the total on hand instead of individual lines for each location.  However, to ease working the report, they wanted to know the lowest numbered location the item was in.

I threw out summarizing the total onhand in the initial result set, and managed to rewrite the query to something like this :

SELECT loc, item, version, Rec_Date, OH, max(TranDate) lasttran from locations left join transactions on  
on Item=Item2and Version=Version2 GROUP BY loc, item, version, rec_date, OH

This runs very fast in strsql where it blocks the results, but, if I apply a sort, or try to retrieve the full set of records, it slows to a crawl.

I know with SQL server, I could create an index Item, Version, trandate and then build a view that would only give me item, version, max(trandate) or a function to return the last transaction date either of which for the 60,000 records I&#039;d be pulling back should be relatively effective.  

We have a very active warehouse with with a huge catalog of items.  Occasional items come into the warehouse, but, never make it out.  Those items then end up taking up space in prime locations.  We&#039;re trying to isolate those items that aren&#039;t active, and relocate them into more appropriate locations.  

I also thought about trying to limit the transactions to just items that are currently in the warehouse.  Unluckily, it trims suprisingly little off of what I&#039;m comparing to (the logical I have reduces the record count to around 6 million (which is probably around 200,000 items)), and the temp file actually would probably slow things down due to lost indexes.  ]]></description>
		<content:encoded><![CDATA[<p>I can&#8217;t index LastTran, last tran is from the subselect which selects item, version, max(tran) I do have a logical that indexes item, version, tran, and I get acceptable results if I run the subquery by itself, (because strsql will retrieve blocks of rows instead of the whole resultset I believe)</p>
<p>the min(loc) was an artifact of me rewriting an anonymized, simplified version of what I&#8217;m pulling back.  An item can be in more then one location, and the report is calling for the total on hand instead of individual lines for each location.  However, to ease working the report, they wanted to know the lowest numbered location the item was in.</p>
<p>I threw out summarizing the total onhand in the initial result set, and managed to rewrite the query to something like this :</p>
<p>SELECT loc, item, version, Rec_Date, OH, max(TranDate) lasttran from locations left join transactions on<br />
on Item=Item2and Version=Version2 GROUP BY loc, item, version, rec_date, OH</p>
<p>This runs very fast in strsql where it blocks the results, but, if I apply a sort, or try to retrieve the full set of records, it slows to a crawl.</p>
<p>I know with SQL server, I could create an index Item, Version, trandate and then build a view that would only give me item, version, max(trandate) or a function to return the last transaction date either of which for the 60,000 records I&#8217;d be pulling back should be relatively effective.  </p>
<p>We have a very active warehouse with with a huge catalog of items.  Occasional items come into the warehouse, but, never make it out.  Those items then end up taking up space in prime locations.  We&#8217;re trying to isolate those items that aren&#8217;t active, and relocate them into more appropriate locations.  </p>
<p>I also thought about trying to limit the transactions to just items that are currently in the warehouse.  Unluckily, it trims suprisingly little off of what I&#8217;m comparing to (the logical I have reduces the record count to around 6 million (which is probably around 200,000 items)), and the temp file actually would probably slow things down due to lost indexes.  </p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/10 queries in 0.035 seconds using memcached
Object Caching 323/329 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-23 13:36:48 -->