My Oracle Support Banner

Wrong Results Caused by Subquery Partition Pruning Against Partition Key of Char Column (Doc ID 2431737.1)

Last updated on DECEMBER 12, 2019

Applies to:

Oracle Database - Enterprise Edition - Version 11.2.0.4 to 11.2.0.4 [Release 11.2]
Oracle Database - Enterprise Edition - Version 12.1.0.2 to 12.1.0.2 [Release 12.1]
Information in this document applies to any platform.

Symptoms

NOTE: In the images and/or the document content below, the user information and data used represents fictitious data from the Oracle sample schema(s) or Public Documentation delivered with an Oracle database product.  Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner.

 

 CREATE TABLE "USER_TAB1"
(
"PART_NO" CHAR(30) NOT NULL ENABLE,
... ...
 PARTITION BY LIST ("PART_NO")
(
PARTITION "P_010000_0000"  VALUES ('00100000000000000')
... ...
PARTITION "P_020000_0000"  VALUES ('00200000000000000')
... ...
PARTITION "P_180201_1802"  VALUES ('00120180201201802') *<<<<<<<<-----------Target Partition
... ...
PARTITION "P_180202_1803"  VALUES ('00120180202201803')
... ...
PARTITION "P_180301_1803"  VALUES ('00120180301201803') *<<<<<<<<-----------Target Partition
... ...
;

 

        0          0          0        HASH JOIN  (cr=4 pr=0 pw=0 time=2176 us cost=188980 size=24612104 card=279683)
        2          2          2         TABLE ACCESS FULL USER_TAB2 (cr=2 pr=0 pw=0 time=42 us cost=3 size=105 card=3) *<<<<<<<<----------- 2 PARTITION KEY is fetched
        0          0          0         PARTITION LIST SUBQUERY PARTITION: KEY(SUBQUERY) KEY(SUBQUERY) (cr=2 pr=0 pw=0 time=1962 us cost=188974 size=59292796 card=1118732) *<<<<<<<<----------- Partition pruning is done.
        0          0          0          TABLE ACCESS FULL USER_TAB1 PARTITION: KEY(SUBQUERY) KEY(SUBQUERY) (cr=0 pr=0 pw=0 time=0 us cost=188974 size=59292796 card=1118732) *<<<<<<<<----------- No partition is selected, so cr is 0

 

SQL> SELECT
           DISTINCT TBL$OR$IDX$PART$NUM (
           "USER_TAB1"
           ,0
           ,1
           ,0
         ,RTRIM( "PART_NO" )
       )
      FROM
       (
        SELECT
                 RTRIM( "USER_TAB2"."PART_NO" ) "PART_NO"
          FROM
                 "USER_TAB2" "USER_TAB2"
        WHERE
                      "USER_TAB2"."FLG" = 1
                 AND "USER_TAB2"."CD" = '001'
     )
   ORDER BY
         1
;

TBL$OR$IDX$PART$NUM("USER_TAB1",0,1,0,RTRIM("PART_NO"))
-------------------------------------------------------
                                                     0

 

 

SQL> SELECT
           DISTINCT TBL$OR$IDX$PART$NUM (
           "USER_TAB1"
           ,0
           ,1
           ,0
           ,"PART_NO"
       )
      FROM
       (
        SELECT
                 RTRIM( "USER_TAB2"."PART_NO" ) "PART_NO"
          FROM
                 "USER_TAB2" "USER_TAB2"
        WHERE
                      "USER_TAB2"."FLG" = 1
                 AND "USER_TAB2"."CD" = '001'
     )
   ORDER BY
         1
;

TBL$OR$IDX$PART$NUM("USER_TAB1",0,1,0,"PART_NO")
-------------------------------------------------------
                                                     3
                                                     5

  

 

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Changes
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.