Select * from v$version
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
I have a problem with local bitmap index not getting used in a specific scenario when I have an equi join with time dimension. I have tested in 2 scenarios and the results are below.
My scenario below has a fact which is list partitioned monthly on std_accounting_period.
Query A joins the fact with time and the other dimension (booking code) to aggregate data for a year for specific booking codes. Its supposed to hit 12 partitions and it does that but it does a full scan on the partitions and is not taking advantage of the bitmap index defined on the Booking code column
The number of distinct values on booking code is 244 in a 55 million table and it has frequency based histogram also defined. Each partition has on an average 1 million records.
In Query B I have joined the fact with booking code without time dimension and passed the 12 std accounting periods in an INLIST. And here I see the bitmap used. Can you please help me in understanding if there is an Oracle issue or I am doing something incorrect?
I saw Jonathan Lewis addressing some issues with local bitmap indexes with list partitioned tables.
Jonathan lewis has written on this
http://jonathanlewis.wordpress.com/2010/11/03/list-partitions/ A) Query with equi join
SELECT
/*+ gather_plan_statistics */
T1274643.period_name,
SUM(a.PERIOD_NET_CR) AS c1,
SUM(a.PERIOD_NET_DR) AS c2,
SUM(a.BEGIN_BALANCE_CR) AS c3,
SUM(a.BEGIN_BALANCE_DR) AS c4
FROM P_GL_BALANCE_TEMP a ,
P_PERIOD T1274643,
P_BOOKING_CODE T1274349
WHERE std_accounting_period = T1274643.period_name
AND T1274643.PERIOD_YEAR ='2011'
AND T1274643.PERIOD_SET ='Std Accounting'
AND T1274643.ADJUSTMENT_FLAG='N' and period_type <> 'Quarter' and period_type <> 'Year'
AND T1274349.BC = a.BC
AND concat(concat(T1274349.BC, ' - '), T1274349.BC_DESC) = '123B - XYZ Services Ltd.'
AND concat(concat(T1274349.LEVEL_2_CODE, ' - '), T1274349.LEVEL_2_DESC) = 'XYZ - World excluding US'
AND concat(concat(T1274349.LEVEL_3_CODE, ' - '), T1274349.LEVEL_3_DESC) = 'XYZ - World excluding US/UK/Europe'
AND concat(concat(T1274349.LEVEL_4_CODE, ' - '), T1274349.LEVEL_4_DESC) = 'XYZ - INDIA'
AND T1274349.LEVEL_1_CODE = 'GEOTOTAL'
GROUP BY T1274643.period_name
Plan hash value: 4200736382
----------------------------------------------------------------------------------
|Id|Operation |Name |Starts|E-Rows|A-Rows|Buffers|
----------------------------------------------------------------------------------
|0 |SELECT STATEMENT | | 1| | 9| 102K|
|1 | HASH GROUP BY | | 1| 15 | 9| 102K|
|2 | NESTED LOOPS | | 1| 1210 | 17698| 102K|
|3 | MERGE JOIN CARTESIAN | | 1| 1 | 12| 9 |
|*4| TABLE ACCESS BY INDEX ROWID|P_BOOKING_CODE | 1| 1 | 1| 2 |
|*5| INDEX RANGE SCAN |P_BOOKING_CODE_I1| 1| 1 | 1| 1 |
|6 | BUFFER SORT | | 1| 15 | 12| 7 |
|*7| TABLE ACCESS FULL |P_PERIOD | 1| 15 | 12| 7 |
|8 | PARTITION LIST ITERATOR | | 12| 5021 | 17698| 102K|
|*9| TABLE ACCESS FULL |P_GL_BALANCE_TEMP| 12| 5021 | 17698| 102K|
----------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - filter(("LEVEL_4_CODE"||' - '||"LEVEL_4_DESC"='XYZ - INDIA' AND "LEVEL_3_CODE"||' -
'||"LEVEL_3_DESC"='XYZ - World excluding US/UK/Europe' AND "LEVEL_2_CODE"||' -
'||"LEVEL_2_DESC"='XYZ - World excluding US' AND "T1274349"."LEVEL_1_CODE"='GEOTOTAL'))
5 - access("T1274349"."SYS_NC00053$"='123B - XYZ Services Ltd.')
7 - filter(("T1274643"."PERIOD_YEAR"=2011 AND "T1274643"."PERIOD_SET"='Std Accounting' AND
"T1274643"."ADJUSTMENT_FLAG"='N' AND "PERIOD_TYPE"<>'Quarter' AND "PERIOD_TYPE"<>'Year'))
9 - filter(("STD_ACCOUNTING_PERIOD"="T1274643"."PERIOD_NAME" AND "T1274349"."BC"="A"."BC"))
B) Query with inlist
select /*+ gather_plan_statistics */ a.std_accounting_period,
SUM(a.PERIOD_NET_CR) AS c1,
SUM(a.PERIOD_NET_DR) AS c2,
SUM(a.BEGIN_BALANCE_CR) AS c3,
SUM(a.BEGIN_BALANCE_DR) AS c4
FROM P_GL_BALANCE_TEMP a , P_BOOKING_CODE T1274349
WHERE T1274349.BC = a.BC
AND concat(concat(T1274349.BC, ' - '), T1274349.BC_DESC) = '123B - XYZ Services Ltd.'
AND concat(concat(T1274349.LEVEL_2_CODE, ' - '), T1274349.LEVEL_2_DESC) = 'XYZ - World excluding US'
AND concat(concat(T1274349.LEVEL_3_CODE, ' - '), T1274349.LEVEL_3_DESC) = 'XYZ - World excluding US/UK/Europe'
AND concat(concat(T1274349.LEVEL_4_CODE, ' - '), T1274349.LEVEL_4_DESC) = 'XYZ - INDIA'
AND T1274349.LEVEL_1_CODE = 'GEOTOTAL'
AND a.std_accounting_period IN ('JAN-11','FEB-11','MAR-11','APR-11','MAY-11','JUN-11','JUL-11','AUG-11','SEP-11','OCT-11','NOV-11','DEC-11')
GROUP BY a.std_accounting_period
-------------------------------------------------------------------------------------------
|Id|Operation |Name |Starts|E-Rows|A-Rows| Buffers |
-------------------------------------------------------------------------------------------
| 0|SELECT STATEMENT | | 1| | 9| 9537 |
| 1| HASH GROUP BY | | 1| 12| 9| 9537 |
| 2| NESTED LOOPS | | 1| | 17698| 9537 |
| 3| NESTED LOOPS | | 1| 952| 17698| 23 |
|*4| TABLE ACCESS BY INDEX ROWID |P_BOOKING_CODE | 1| 1| 1| 2 |
|*5| INDEX RANGE SCAN |P_BOOKING_CODE_I1 | 1| 1| 1| 1 |
| 6| PARTITION LIST INLIST | | 1| | 17698| 21 |
| 7| BITMAP CONVERSION TO ROWIDS | | 12| | 17698| 21 |
|*8| BITMAP INDEX SINGLE VALUE |IND_03_P_GL_BALANC| 12| | 9| 21 |
| 9| TABLE ACCESS BY LOCAL INDEX ROWID|P_GL_BALANCE_TEMP | 17698| 60946| 17698| 9514 |
-------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - filter(("LEVEL_4_CODE"||' - '||"LEVEL_4_DESC"='XYZ - INDIA' AND "LEVEL_3_CODE"||' -
'||"LEVEL_3_DESC"='XYZ - World excluding US/UK/Europe' AND "LEVEL_2_CODE"||' -
'||"LEVEL_2_DESC"='XYZ - World excluding US' AND "T1274349"."LEVEL_1_CODE"='GEOTOTAL'))
5 - access("T1274349"."SYS_NC00053$"='123B - XYZ Services Ltd.')
8 - access("T1274349"."BC"="A"."BC")