Wednesday, January 30, 2013

Bug: ORA-00979: not a GROUP BY expression

Bugs and performance degradation are part of database upgrade stories and we have witnessed yet another post-upgrade bug after upgrading our database from Oracle 10gR2 (10.2.0.5) to Oracle 11gR2 (11.2.0.2). 

Following query (I have simplified the query for the demonstration purpose) was running happily within Oracle 10gR2:


SQL>
SQL> select * from ( select TRUNC(dt,'MM')
  2          from test
  3          group by TRUNC(dt,'mm'));

TRUNC(DT,
---------
01-JAN-13

SQL>


However, the same query started to throws an error (ORA-00979) when executed in Oracle 11gR2 (11.2.0.2): 


SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

SQL> 


SQL> select * from ( select TRUNC(dt,'MM')
          from test
          group by TRUNC(dt,'mm'));
  2    3  select * from ( select TRUNC(dt,'MM')
                             *
ERROR at line 1:
ORA-00979: not a GROUP BY expression


SQL> 



At this point I normally do a search on My Oracle Support (MOS) to see if I get  some hits pertaining to this problem and found the following bug information:



Bug 11067251 - False ORA-979 with TRUNC(date, format) or ROUND(date, format) - superceded [ID 11067251.8]


Apparently, you hit the bug when you use either TRUNC or ROUND functions in an inline view. Executing the same query with little modification (removing inline view) in 11.2.0.2 was however successful.


SQL> select TRUNC(dt,'MM')
 from test
group by TRUNC(dt,'mm');
  2    3  
TRUNC(DT,
---------
01-JAN-13

SQL> 

The above bug confirms that 11.2.0.2 is affected and proposes following two workarounds: 

1) Use NO_MERGE hint or
2) Disable view merging "_simple_view_merging=false" 

As it was not possible to rewrite the application at this point, so we disabled view merging at the system level. Well, disabling view merging at the system level might appear as a bad choice but I think it is a right decision at this time. We will soon be upgrading this database to 11.2.0.3. This will kill two birds with one stone, a) bug fix and b) upgrading to the latest patch level (who knows what new bugs are waiting for us ???).

References: 

  • My Oracle Support:  Bug 11067251 - False ORA-979 with TRUNC(date, format) or ROUND(date, format) - superceded [ID 11067251.8]


Wednesday, October 10, 2012

Online Free Courses from World's Best Universities


Coursera is offering courses free online. The courses are delivered from faculty members of top universities in the world. You may find more information on the courses at:

https://www.coursera.org/


Happy learning !!!

Thursday, October 04, 2012

OOW-2012: Oracle 12c New Features

Blogging right from Tom's session "database new features". Here are the new features as they are discussed:

1. Identity Columns

Remember I blogged on this topic earlier.

2. Default on null

A default value is inserted into the column When it's null.

3. Improved defaults - metadata only defaults

Now add new default columns to a table on the fly. 12c does that for you.

4. Increased size limit for Varchar2 and NVarchar2

The column types can be upto 32k.

5. Row Pattern Matching

Efficient SQL functionality for reporting row patterns like identifying V and W patterns for your stock

6. Partitioning Improvements

Online partition movement without using DBMS_REDEFINITION. Efficient global index management during DROP and TRUNCATE partition operation.


7. Hybrid Histograms

Jonathan Lewis spoke on this topic. I think more information on this is available on his blog.

8. Session private statistics for GTTs

Table and index statistics are held private for each session.

9. Temporary UNDO
Undo for temporary tables can now be managed in TEMP. Reduces the amount of undo generated in undo tablespace and redo generation.

10. Pluggable databases

Read Roels blog for this one. He has a good blog post on this

http://roelhartman.blogspot.com/