<?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: Oracle 11g: Unexpected Difference Between count(*) and count(1)</title>
	<atom:link href="http://www.pythian.com/news/627/oracle-11g-unexpected-difference-between-count-and-count1/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pythian.com/news/627/oracle-11g-unexpected-difference-between-count-and-count1/</link>
	<description>News and views from Pythian DBAs</description>
	<lastBuildDate>Fri, 10 Feb 2012 13:01:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Virgile Crevon</title>
		<link>http://www.pythian.com/news/627/oracle-11g-unexpected-difference-between-count-and-count1/#comment-122402</link>
		<dc:creator>Virgile Crevon</dc:creator>
		<pubDate>Thu, 08 Nov 2007 22:11:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/627/oracle-11g-unexpected-difference-between-count-and-count1#comment-122402</guid>
		<description>Hi Greg,

Check about improvement concerning 11G, this is the key.  I&#039;ve found that behavior is call &quot;Fine grained dependency tracking&quot;.

While certain things require view to be invalidated, somes do not. For example with DDL &quot;ADD COLUMN&quot; :
count(*), select *, select col1 (must exist before the add). And so on.

Check this one http://laurentschneider.com/wordpress/2006/10/11g-new-features.html

I quote Laurent Schneider :
&quot;
Fine grained dependency tracking. Currently, if you have a view or a function based on a table, and if you modify that table, the view is getting invalid. This is what Bryn called : aggressive object invalidation. Now in 11g it has improved, so if you modify an element of the table which is not included in that view (ex: you add a column), the view is not invalidated. This is wise.
&quot; 

Regards,

Virgile CREVON</description>
		<content:encoded><![CDATA[<p>Hi Greg,</p>
<p>Check about improvement concerning 11G, this is the key.  I&#8217;ve found that behavior is call &#8220;Fine grained dependency tracking&#8221;.</p>
<p>While certain things require view to be invalidated, somes do not. For example with DDL &#8220;ADD COLUMN&#8221; :<br />
count(*), select *, select col1 (must exist before the add). And so on.</p>
<p>Check this one <a href="http://laurentschneider.com/wordpress/2006/10/11g-new-features.html" rel="nofollow">http://laurentschneider.com/wordpress/2006/10/11g-new-features.html</a></p>
<p>I quote Laurent Schneider :<br />
&#8221;<br />
Fine grained dependency tracking. Currently, if you have a view or a function based on a table, and if you modify that table, the view is getting invalid. This is what Bryn called : aggressive object invalidation. Now in 11g it has improved, so if you modify an element of the table which is not included in that view (ex: you add a column), the view is not invalidated. This is wise.<br />
&#8221; </p>
<p>Regards,</p>
<p>Virgile CREVON</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pythian Group Blog &#187; Blog Archive &#187; Log Buffer #66: a Carnival of the Vanities for DBAs</title>
		<link>http://www.pythian.com/news/627/oracle-11g-unexpected-difference-between-count-and-count1/#comment-111914</link>
		<dc:creator>Pythian Group Blog &#187; Blog Archive &#187; Log Buffer #66: a Carnival of the Vanities for DBAs</dc:creator>
		<pubDate>Fri, 12 Oct 2007 16:38:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/627/oracle-11g-unexpected-difference-between-count-and-count1#comment-111914</guid>
		<description>[...] GrÃ©gory Guillou discovered an unexpected difference between count(*) and count(1). Also here at home, Robert Hamel gives a bad rating to 11g&#8217;s new pivot table feature. [...]</description>
		<content:encoded><![CDATA[<p>[...] GrÃ©gory Guillou discovered an unexpected difference between count(*) and count(1). Also here at home, Robert Hamel gives a bad rating to 11g&#8217;s new pivot table feature. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shakespeare</title>
		<link>http://www.pythian.com/news/627/oracle-11g-unexpected-difference-between-count-and-count1/#comment-111130</link>
		<dc:creator>Shakespeare</dc:creator>
		<pubDate>Wed, 10 Oct 2007 08:11:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/627/oracle-11g-unexpected-difference-between-count-and-count1#comment-111130</guid>
		<description>Sorry for that count(null), different discussion, should return 0 at any time... was a discussion about select null from dual.</description>
		<content:encoded><![CDATA[<p>Sorry for that count(null), different discussion, should return 0 at any time&#8230; was a discussion about select null from dual.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.pythian.com/news/627/oracle-11g-unexpected-difference-between-count-and-count1/#comment-108549</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 04 Oct 2007 15:41:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/627/oracle-11g-unexpected-difference-between-count-and-count1#comment-108549</guid>
		<description>I just verified this is indeed different from behaviour in 10.2.0.3 on Solaris 10:
(9.2.0.8 as well)

SQL*Plus: Release 10.2.0.3.0 - Production on Thu Oct 4 17:38:11 2007

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

SQL&gt; 
SQL&gt; -- create simple table
SQL&gt; 
SQL&gt; create table gg(
  2     col1 number);

Table created.

SQL&gt; 
SQL&gt; -- create two distinct views of this table as below :
SQL&gt; -- gg_v1 makes use of a count(1)
SQL&gt; -- gg_v2 makes use of a count(*)
SQL&gt; 
SQL&gt; create view gg_v1 as
  2   select count(1) num from gg;

View created.

SQL&gt; 
SQL&gt; create view gg_v2 as
  2   select count(*) num from gg;

View created.

SQL&gt; 
SQL&gt; -- check that these two views are valid.
SQL&gt; 
SQL&gt; col object_name format a10
SQL&gt; col object_type format a5
SQL&gt; col status format a8
SQL&gt; 
SQL&gt; select object_name, object_type, status
  2    from user_objects
  3   where (object_name=&#039;GG_V1&#039;
  4          or object_name=&#039;GG_V2&#039;)
  5     and object_type = &#039;VIEW&#039;
  6   order by object_name, object_type;

OBJECT_NAM OBJEC STATUS
---------- ----- --------
GG_V1      VIEW  VALID
GG_V2      VIEW  VALID

SQL&gt; 
SQL&gt; -- And then add a column:
SQL&gt; 
SQL&gt; alter table gg add (col2 number);

Table altered.

SQL&gt; 
SQL&gt; -- 2. Display the result
SQL&gt; 
SQL&gt; -- The query below displays the status of the two views after the change on the table:
SQL&gt; 
SQL&gt; col object_name format a10
SQL&gt; col object_type format a5
SQL&gt; col status format a8
SQL&gt; 
SQL&gt; select object_name, object_type, status
  2    from user_objects
  3   where (object_name=&#039;GG_V1&#039;
  4          or object_name=&#039;GG_V2&#039;)
  5     and object_type = &#039;VIEW&#039;
  6   order by object_name, object_type;

OBJECT_NAM OBJEC STATUS
---------- ----- --------
GG_V1      VIEW  INVALID
GG_V2      VIEW  INVALID

SQL&gt; 
SQL&gt; 
SQL&gt; drop table gg;

Table dropped.

SQL&gt; 
SQL&gt; drop view gg_v1;

View dropped.

SQL&gt; 
SQL&gt; drop view gg_v2;

View dropped.

SQL&gt;</description>
		<content:encoded><![CDATA[<p>I just verified this is indeed different from behaviour in 10.2.0.3 on Solaris 10:<br />
(9.2.0.8 as well)</p>
<p>SQL*Plus: Release 10.2.0.3.0 &#8211; Production on Thu Oct 4 17:38:11 2007</p>
<p>Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.</p>
<p>Connected to:<br />
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 &#8211; 64bit Production<br />
With the Partitioning, OLAP and Data Mining options</p>
<p>SQL&gt;<br />
SQL&gt; &#8212; create simple table<br />
SQL&gt;<br />
SQL&gt; create table gg(<br />
  2     col1 number);</p>
<p>Table created.</p>
<p>SQL&gt;<br />
SQL&gt; &#8212; create two distinct views of this table as below :<br />
SQL&gt; &#8212; gg_v1 makes use of a count(1)<br />
SQL&gt; &#8212; gg_v2 makes use of a count(*)<br />
SQL&gt;<br />
SQL&gt; create view gg_v1 as<br />
  2   select count(1) num from gg;</p>
<p>View created.</p>
<p>SQL&gt;<br />
SQL&gt; create view gg_v2 as<br />
  2   select count(*) num from gg;</p>
<p>View created.</p>
<p>SQL&gt;<br />
SQL&gt; &#8212; check that these two views are valid.<br />
SQL&gt;<br />
SQL&gt; col object_name format a10<br />
SQL&gt; col object_type format a5<br />
SQL&gt; col status format a8<br />
SQL&gt;<br />
SQL&gt; select object_name, object_type, status<br />
  2    from user_objects<br />
  3   where (object_name=&#8217;GG_V1&#8242;<br />
  4          or object_name=&#8217;GG_V2&#8242;)<br />
  5     and object_type = &#8216;VIEW&#8217;<br />
  6   order by object_name, object_type;</p>
<p>OBJECT_NAM OBJEC STATUS<br />
&#8212;&#8212;&#8212;- &#8212;&#8211; &#8212;&#8212;&#8211;<br />
GG_V1      VIEW  VALID<br />
GG_V2      VIEW  VALID</p>
<p>SQL&gt;<br />
SQL&gt; &#8212; And then add a column:<br />
SQL&gt;<br />
SQL&gt; alter table gg add (col2 number);</p>
<p>Table altered.</p>
<p>SQL&gt;<br />
SQL&gt; &#8212; 2. Display the result<br />
SQL&gt;<br />
SQL&gt; &#8212; The query below displays the status of the two views after the change on the table:<br />
SQL&gt;<br />
SQL&gt; col object_name format a10<br />
SQL&gt; col object_type format a5<br />
SQL&gt; col status format a8<br />
SQL&gt;<br />
SQL&gt; select object_name, object_type, status<br />
  2    from user_objects<br />
  3   where (object_name=&#8217;GG_V1&#8242;<br />
  4          or object_name=&#8217;GG_V2&#8242;)<br />
  5     and object_type = &#8216;VIEW&#8217;<br />
  6   order by object_name, object_type;</p>
<p>OBJECT_NAM OBJEC STATUS<br />
&#8212;&#8212;&#8212;- &#8212;&#8211; &#8212;&#8212;&#8211;<br />
GG_V1      VIEW  INVALID<br />
GG_V2      VIEW  INVALID</p>
<p>SQL&gt;<br />
SQL&gt;<br />
SQL&gt; drop table gg;</p>
<p>Table dropped.</p>
<p>SQL&gt;<br />
SQL&gt; drop view gg_v1;</p>
<p>View dropped.</p>
<p>SQL&gt;<br />
SQL&gt; drop view gg_v2;</p>
<p>View dropped.</p>
<p>SQL&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shakespeare</title>
		<link>http://www.pythian.com/news/627/oracle-11g-unexpected-difference-between-count-and-count1/#comment-108481</link>
		<dc:creator>Shakespeare</dc:creator>
		<pubDate>Thu, 04 Oct 2007 10:36:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.pythian.com/blogs/627/oracle-11g-unexpected-difference-between-count-and-count1#comment-108481</guid>
		<description>Just for completeness: could you check what happens to select count(null) ? We have had a disussion in a newsgroup about count(1) vs. count(null).</description>
		<content:encoded><![CDATA[<p>Just for completeness: could you check what happens to select count(null) ? We have had a disussion in a newsgroup about count(1) vs. count(null).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

