<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Oracle 11g: Unexpected Difference Between count(*) and count(1)</title>
	<link>http://www.pythian.com/blogs/627/oracle-11g-unexpected-difference-between-count-and-count1</link>
	<description>News and views from Pythian DBAs</description>
	<pubDate>Fri,  8 Aug 2008 21:20:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
		<item>
		<title>By: Virgile Crevon</title>
		<link>http://www.pythian.com/blogs/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>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've found that behavior is call "Fine grained dependency tracking".

While certain things require view to be invalidated, somes do not. For example with DDL "ADD COLUMN" :
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 :
"
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.
" 

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/blogs/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>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>[&#8230;] 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. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shakespeare</title>
		<link>http://www.pythian.com/blogs/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>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/blogs/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>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&#62; 
SQL&#62; -- create simple table
SQL&#62; 
SQL&#62; create table gg(
  2     col1 number);

Table created.

SQL&#62; 
SQL&#62; -- create two distinct views of this table as below :
SQL&#62; -- gg_v1 makes use of a count(1)
SQL&#62; -- gg_v2 makes use of a count(*)
SQL&#62; 
SQL&#62; create view gg_v1 as
  2   select count(1) num from gg;

View created.

SQL&#62; 
SQL&#62; create view gg_v2 as
  2   select count(*) num from gg;

View created.

SQL&#62; 
SQL&#62; -- check that these two views are valid.
SQL&#62; 
SQL&#62; col object_name format a10
SQL&#62; col object_type format a5
SQL&#62; col status format a8
SQL&#62; 
SQL&#62; select object_name, object_type, status
  2    from user_objects
  3   where (object_name='GG_V1'
  4          or object_name='GG_V2')
  5     and object_type = 'VIEW'
  6   order by object_name, object_type;

OBJECT_NAM OBJEC STATUS
---------- ----- --------
GG_V1      VIEW  VALID
GG_V2      VIEW  VALID

SQL&#62; 
SQL&#62; -- And then add a column:
SQL&#62; 
SQL&#62; alter table gg add (col2 number);

Table altered.

SQL&#62; 
SQL&#62; -- 2. Display the result
SQL&#62; 
SQL&#62; -- The query below displays the status of the two views after the change on the table:
SQL&#62; 
SQL&#62; col object_name format a10
SQL&#62; col object_type format a5
SQL&#62; col status format a8
SQL&#62; 
SQL&#62; select object_name, object_type, status
  2    from user_objects
  3   where (object_name='GG_V1'
  4          or object_name='GG_V2')
  5     and object_type = 'VIEW'
  6   order by object_name, object_type;

OBJECT_NAM OBJEC STATUS
---------- ----- --------
GG_V1      VIEW  INVALID
GG_V2      VIEW  INVALID

SQL&#62; 
SQL&#62; 
SQL&#62; drop table gg;

Table dropped.

SQL&#62; 
SQL&#62; drop view gg_v1;

View dropped.

SQL&#62; 
SQL&#62; drop view gg_v2;

View dropped.

SQL&#62;</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 - 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 - 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/blogs/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>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>
