<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>永远的风&#187; 程序设计</title>
	<atom:link href="http://www.yinux.com/category/program/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yinux.com</link>
	<description>局部地方</description>
	<lastBuildDate>Sun, 13 Jun 2010 09:47:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://goodbee.superfeedr.com/"/>	<!-- podcast_generator="podPress/8.8" - maintenance_release="8.8.4" -->
		<copyright>Copyright &#xA9; 2010 永远的风 </copyright>
		<managingEditor>yinyuanchao@gmail.com ()</managingEditor>
		<webMaster>yinyuanchao@gmail.com ()</webMaster>
		<category>posts</category>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle></itunes:subtitle>
		<itunes:summary>局部地方</itunes:summary>
		<itunes:author></itunes:author>
		<itunes:category text="Society &amp; Culture"/>
		<itunes:owner>
			<itunes:name></itunes:name>
			<itunes:email>yinyuanchao@gmail.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://www.yinux.com/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://www.yinux.com/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>永远的风</title>
			<link>http://www.yinux.com</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>转一篇quest Xpert for PL/SQL 的&#8212;&#8212;-Avoid COUNT(*) Unless Count is Required</title>
		<link>http://www.yinux.com/2006/11/to_a_quest_xpert_for_plsql/</link>
		<comments>http://www.yinux.com/2006/11/to_a_quest_xpert_for_plsql/#comments</comments>
		<pubDate>Wed, 29 Nov 2006 16:15:09 +0000</pubDate>
		<dc:creator>goodbee</dc:creator>
				<category><![CDATA[DATABASE]]></category>
		<category><![CDATA[社会 新闻]]></category>

		<guid isPermaLink="false">http://www.yinux.com/?p=78</guid>
		<description><![CDATA[之前，我还真没想过用rownum来提高性能。至于用游标循环，倒是很简单。Avoid COUNT(*) Unless Count is RequiredConsider the following requirement:Get the ID for the company which matches specified name.If no match, display error.If more than one match, show list.If single match, return... [...]]]></description>
			<content:encoded><![CDATA[<p>之前，我还真没想过用rownum来提高性能。至于用游标循环，倒是很简单。</p>
<p>Avoid COUNT(*) Unless Count is Required<br />
Consider the following requirement:<br />
Get the ID for the company which matches specified name.<br />
If no match, display error.<br />
If more than one match, show list.<br />
If single match, return ID.<br />
How do you handle this situation? The most obvious and common solution is to use COUNT to figure out how many matches you have for the name, and then execute logic from there. But are you really answering the &#8220;right question?&#8221;<br />
When you do a COUNT, you find out how many matches there are. If you don&#8217;t really care how many, but just that there is more than one match, COUNT is overkill. For example:</p>
<p>BEGIN<br />
SELECT COUNT(*) INTO the_count<br />
FROM company<br />
WHERE name LIKE :cllr.cname;<br />
IF the_count = 1<br />
THEN<br />
SELECT company_id INTO the_id<br />
FROM company<br />
WHERE name = :cllr.cname;<br />
return_value (the_id);<br />
ELSIF the_count &gt; 1<br />
THEN<br />
show_list;<br />
ELSIF the_count = 0<br />
THEN<br />
display (&#8216;No matches found.&#8217;);<br />
END IF;<br />
END;<br />
Notice a second SELECT has to be executed to retrieve the single ID. In this case, we don’t have to worry about NO_DATA_FOUND, since COUNT returns 0 if no rows found.</p>
<p>A better solution is to use two fetches instead:</p>
<p>DECLARE<br />
CURSOR comp_cur IS &#8230;;<br />
comp_rec comp_cur%ROWTYPE;<br />
BEGIN<br />
OPEN comp_cur;<br />
FETCH comp_cur INTO comp_rec;<br />
IF comp_cur%NOTFOUND<br />
THEN<br />
display (&#8216;No match found.&#8217;);<br />
ELSE<br />
FETCH comp_cur INTO comp_rec;<br />
IF comp_cur%FOUND<br />
THEN<br />
show_list;<br />
ELSE<br />
:employee.company_id :=<br />
comp_rec.company_id;<br />
:employee.company_nm :=<br />
comp_rec.company_nm;<br />
END IF;<br />
END IF;<br />
CLOSE comp_cur; END;</p>
<p>Advantages of Dual Fetch Approach<br />
Absolute minimum of CPU and memory employed to meet requirement.<br />
Avoids duplication of SQL statement.<br />
You would have to maintain the WHERE clause in both as there were database changes.<br />
Be sure to read your requirements carefully and decide on the most sensible approach.<br />
What seems at first glance to be the most sensible solution may turn out to have major drawbacks.</p>
<p>What about an “Efficient” COUNT(*)?<br />
SELECT COUNT(*) INTO my_count<br />
FROM emp<br />
WHERE empno = emp_in<br />
AND ROWNUM &lt; 2;<br />
In the above implicit cursor, ROWNUM is used to make sure that only one row is retrieved. This query will not ever return a value greater than one, and it will return 0 if no matches are found. A good fit?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yinux.com/2006/11/to_a_quest_xpert_for_plsql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>今天才听说MapReduce</title>
		<link>http://www.yinux.com/2006/09/today_heard_that_mapreduce/</link>
		<comments>http://www.yinux.com/2006/09/today_heard_that_mapreduce/#comments</comments>
		<pubDate>Tue, 12 Sep 2006 21:39:15 +0000</pubDate>
		<dc:creator>goodbee</dc:creator>
				<category><![CDATA[DATABASE]]></category>
		<category><![CDATA[编程 软件]]></category>

		<guid isPermaLink="false">http://www.yinux.com/?p=72</guid>
		<description><![CDATA[什么是MapReduce? Google的分布运算开发工具MapReduce，用于大规模数据集（大于1TB）的并行运算! 可以定义一些函数，对批量数据进行操作。比如可以定义使每个数据乘以二的函数，这样，可以并行执行，而且可以分发到不同服务器进行分布式运算。而且，在某些时候，即使是单机运算也有不小的意义，比如求平均数时很容易就可以实现，相邻数相加的运算，可以使参与运算的项快速减少一半。如果采用普通算法逐个运算。首先，如果一直加下去，很容易溢出，如果采用边加边计算，逐项求平均，很容易造成精确度丢失，... [...]]]></description>
			<content:encoded><![CDATA[<p>什么是MapReduce? Google的分布运算开发工具MapReduce，用于大规模数据集（大于1TB）的并行运算! 可以定义一些函数，对批量数据进行操作。比如可以定义使每个数据乘以二的函数，这样，可以并行执行，而且可以分发到不同服务器进行分布式运算。而且，在某些时候，即使是单机运算也有不小的意义，比如求平均数时很容易就可以实现，相邻数相加的运算，可以使参与运算的项快速减少一半。如果采用普通算法逐个运算。首先，如果一直加下去，很容易溢出，如果采用边加边计算，逐项求平均，很容易造成精确度丢失，解决这个问题的算法可能会相当复杂。</p>
<p>   当然，这只是MapReduce功能的冰山一角。google的成功绝对不是偶然的。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yinux.com/2006/09/today_heard_that_mapreduce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
