Database Tuning (MOSC)

MOSC Banner

Wrong Results from Query Rewrite

edited Feb 6, 2009 12:43AM in Database Tuning (MOSC) 4 commentsAnswered
Hi,

Oracle 10.2.0.4 on Solaris 9

We have noticed wrong results occuring during query rewrite involving table 1 and table 2. Each of these tables have a MV. This problem is noticed only when a sub query is employed for the IN operator. Here is sample query:

Query 1 -

SQL>SELECT COUNT(1) FROM tab1
WHERE END_EFF_DATE=TO_DATE('31-DEC-9999','DD-MON-YYYY')  
  AND RECIP_ID IN (SELECT RECIP_ID FROM tab2
                   WHERE END_EFF_DATE=TO_DATE('31-DEC-9999','DD-MON-YYYY')  
                     AND RELATIONSHIP_IND IN ('04','05')
                  ); 
COUNT(1)

----------

3015026

The result is different (and correct) when the distinct is used in the sub query as below -

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center