Why does not my query use an index?

I have a table with some processed rows (state: 9) and some unprocessed rows (states: 0,1,2,3,4).
This table has over 120000 rows, but this number will grow.
Most of the rows are processed and most of them also contain a group id. Number of groups is relatively small (let's assume 20).
I would like to obtain the oldest some_date for every group. This values has to be outer joined to a on-line report (contains one row for each group).
Here is my set-up:
Tested on: 10.2.0.4 (Solaris), 10.2.0.1 (WinXp)
drop table t purge;
create table t(
  id number not null primary key,
  grp_id number,
  state number,
  some_date date,
  pad char(200)
insert into t(id, grp_id, state, some_date, pad)
select level,
     trunc(dbms_random.value(0,20)),
        9,
        sysdate+dbms_random.value(1,100),
        'x'
from dual
connect by level <= 120000;
insert into t(id, grp_id, state, some_date, pad)
select level + 120000,
     trunc(dbms_random.value(0,20)),
        trunc(dbms_random.value(0,5)),
        sysdate+dbms_random.value(1,100),
        'x'
from dual
connect by level <= 2000;
commit;
exec dbms_stats.gather_table_stats(user, 'T', estimate_percent=>100, method_opt=>'FOR ALL COLUMNS SIZE 1');
Tom Kyte's printtab
==============================
TABLE_NAME                    : T
NUM_ROWS                      : 122000
BLOCKS                        : 3834I know, this could be easily solved by fast refresh on commit materialized view like this:
select
  grp_id,
  min(some_date),
from
  t
where
  state in (0,1,2,3,4)
grpup by
  grp_id;+ I have to create log on (grp_id, some_date, state)
Number of rows with active state will be always relatively small. Let's assume 1000-2000.
So my another idea was to create a selective index. An index which would contain only data for rows with an active state.
Something like this:
create index fidx_active on t ( 
  case state 
    when 0 then grp_id
    when 1 then grp_id
    when 2 then grp_id
    when 3 then grp_id
    when 4 then grp_id
  end,
  case state
    when 0 then some_date
    when 1 then some_date
    when 2 then some_date
    when 3 then some_date
    when 4 then some_date
  end) compress 1; so a tuple (group_id, some_date) is projected to tuple (null, null) when the state is not an active state and therefore it is not indexed.
We can save even more space by compressing 1st expression.
analyze index idx_grp_state_date validate structure;
select * from index_stats
@pr
Tom Kyte's printtab
==============================
HEIGHT                        : 2
BLOCKS                        : 16
NAME                          : FIDX_ACTIV
LF_ROWS                       : 2000 <-- we're indexing only active rows
LF_BLKS                       : 6 <-- small index: 1 root block with 6 leaf blocks
BR_ROWS                       : 5
BR_BLKS                       : 1
DISTINCT_KEYS                 : 2000
PCT_USED                      : 69
PRE_ROWS                      : 25
PRE_ROWS_LEN                  : 224
OPT_CMPR_COUNT                : 1
OPT_CMPR_PCTSAVE              : 0Note: @pr is a Tom Kyte's print table script adopted by Tanel Poder (I'm using Tanel's library) .
Then I created a query to be outer joined to the report (report contains a row for every group).
I want to achieve a full scan of the index.
select
  case state -- 1st expression
    when 0 then grp_id
    when 1 then grp_id
    when 2 then grp_id
    when 3 then grp_id
    when 4 then grp_id
  end grp_id,
  min(case state --second expression
        when 0 then some_date
        when 1 then some_date
        when 2 then some_date
        when 3 then some_date
        when 4 then some_date
      end) as mintime
from t 
where
  case state --1st expression: at least one index column has to be not null
    when 0 then grp_id
    when 1 then grp_id
    when 2 then grp_id
    when 3 then grp_id
    when 4 then grp_id
  end is not null
group by
  case state --1st expression
    when 0 then grp_id
    when 1 then grp_id
    when 2 then grp_id
    when 3 then grp_id
    when 4 then grp_id
  end;-------------
Doc's snippet:
13.5.3.6 Full Scans
A full scan is available if a predicate references one of the columns in the index. The predicate does not need to be an index driver. A full scan is also available when there is no predicate, if both the following conditions are met:
All of the columns in the table referenced in the query are included in the index.
At least one of the index columns is not null.
A full scan can be used to eliminate a sort operation, because the data is ordered by the index key. It reads the blocks singly.
13.5.3.7 Fast Full Index Scans
Fast full index scans are an alternative to a full table scan when the index contains all the columns that are needed for the query, and at least one column in the index key has the NOT NULL constraint. A fast full scan accesses the data in the index itself, without accessing the table. It cannot be used to eliminate a sort operation, because the data is not ordered by the index key. It reads the entire index using multiblock reads, unlike a full index scan, and can be parallelized.
You can specify fast full index scans with the initialization parameter OPTIMIZER_FEATURES_ENABLE or the INDEX_FFS hint. Fast full index scans cannot be performed against bitmap indexes.
A fast full scan is faster than a normal full index scan in that it can use multiblock I/O and can be parallelized just like a table scan.
So the question is: Why does oracle do a full table scan?
Everything needed is in the index and one expression is not null, but index (fast) full scan is not even considered by CBO (I did a 10053 trace)
| Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
|   1 |  HASH GROUP BY     |      |      1 |     85 |     20 |00:00:00.11 |    3841 |
|*  2 |   TABLE ACCESS FULL| T    |      1 |   6100 |   2000 |00:00:00.10 |    3841 |
Predicate Information (identified by operation id):
   2 - filter(CASE "STATE" WHEN 0 THEN "GRP_ID" WHEN 1 THEN "GRP_ID" WHEN 2
              THEN "GRP_ID" WHEN 3 THEN "GRP_ID" WHEN 4 THEN "GRP_ID" END  IS NOT NULL)Let's try some minimalistic examples. Firstly with no FBI.
create index idx_grp_id on t(grp_id);
select grp_id,
       min(grp_id) min
from t
where grp_id is not null
group by grp_id;
| Id  | Operation             | Name       | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
|   1 |  HASH GROUP BY        |            |      1 |     20 |     20 |00:00:01.00 |     244 |    237 |
|*  2 |   INDEX FAST FULL SCAN| IDX_GRP_ID |      1 |    122K|    122K|00:00:00.54 |     244 |    237 |
Predicate Information (identified by operation id):
   2 - filter("GRP_ID" IS NOT NULL)This kind of output I was expected to see with FBI. Index FFS was used although grp_id has no NOT NULL constraint.
Let's try a simple FBI.
create index fidx_grp_id on t(trunc(grp_id));
select trunc(grp_id),
       min(trunc(grp_id)) min
from t
where trunc(grp_id) is not null
group by trunc(grp_id);
| Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
|   1 |  HASH GROUP BY     |      |      1 |     20 |     20 |00:00:00.94 |    3841 |
|*  2 |   TABLE ACCESS FULL| T    |      1 |   6100 |    122K|00:00:00.49 |    3841 |
Predicate Information (identified by operation id):
   2 - filter(TRUNC("GRP_ID") IS NOT NULL)Again, index (fast) full scan not even considered by CBO.
I tried:
alter table t modify grp_id not null;
alter table t add constraint trunc_not_null check (trunc(grp_id) is not null);I even tried to set table hidden column (SYS_NC00008$) to NOT NULL
It has no effect, FTS is still used..
Let's try another query:
select distinct trunc(grp_id)
from t
where trunc(grp_id) is not null
| Id  | Operation             | Name        | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
|   1 |  HASH UNIQUE          |             |      1 |     20 |     20 |00:00:00.85 |     244 |
|*  2 |   INDEX FAST FULL SCAN| FIDX_GRP_ID |      1 |    122K|    122K|00:00:00.49 |     244 |
Predicate Information (identified by operation id):
   2 - filter("T"."SYS_NC00008$" IS NOT NULL)Here the index FFS is used..
Let's try one more query, very similar to the above query:
select trunc(grp_id)
from t
where trunc(grp_id) is not null
group by trunc(grp_id)
| Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
|   1 |  HASH GROUP BY     |      |      1 |     20 |     20 |00:00:00.86 |    3841 |
|*  2 |   TABLE ACCESS FULL| T    |      1 |    122K|    122K|00:00:00.49 |    3841 |
Predicate Information (identified by operation id):
   2 - filter(TRUNC("GRP_ID") IS NOT NULL)And again no index full scan..
So my next question is:
What are the restrictions which prevent index (fast) fullscan to be used in these scenarios?
Thank you very much for your answers.
Edited by: user1175494 on 16.11.2010 15:23
Edited by: user1175494 on 16.11.2010 15:25

I'll start off with the caveat that i'm no Johnathan Lewis so hopefully someone will be able to come along and give you a more coherent explanation than i'm going to attempt here.
It looks like the application of the MIN function against the case statement is confusing the optimizer and disallowing the usage of your FBI. I tested this against my 11.2.0.1 instance and your query chooses the fast full scan without being nudged in the right direction.
That being said, i was able to get this to use a fast full scan on my 10 instance, but i had to jiggle the wires a bit. I modified your original query slightly, just to make it easier to do my fiddling.
original (in the sense that it still takes the full table scan) query
with data as
  select
    case state -- 1st expression
      when 0 then grp_id
      when 1 then grp_id
      when 2 then grp_id
      when 3 then grp_id
      when 4 then grp_id
    end as grp_id,
    case state --second expression
          when 0 then some_date
          when 1 then some_date
          when 2 then some_date
          when 3 then some_date
          when 4 then some_date
    end as mintime
  from t
  where
    case state --1st expression: at least one index column has to be not null
      when 0 then grp_id
      when 1 then grp_id
      when 2 then grp_id
      when 3 then grp_id
      when 4 then grp_id
    end is not null
  and
    case state --second expression
          when 0 then some_date
          when 1 then some_date
          when 2 then some_date
          when 3 then some_date
          when 4 then some_date
    end is not null 
select--+ GATHER_PLAN_STATISTICS
  grp_id,
  min(mintime)
from data
group by grp_id;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL, NULL, 'allstats  +peeked_binds'));
| Id  | Operation        | Name | Starts | E-Rows | A-Rows |      A-Time   | Buffers |
|   1 |  HASH GROUP BY        |       |      2 |      33 |       40 |00:00:00.07 |    7646 |
|*  2 |   TABLE ACCESS FULL| T       |      2 |      33 |     4000 |00:00:00.08 |    7646 |
Predicate Information (identified by operation id):
   2 - filter((CASE "STATE" WHEN 0 THEN "GRP_ID" WHEN 1 THEN "GRP_ID" WHEN 2
           THEN "GRP_ID" WHEN 3 THEN "GRP_ID" WHEN 4 THEN "GRP_ID" END  IS NOT NULL AND
           CASE "STATE" WHEN 0 THEN "SOME_DATE" WHEN 1 THEN "SOME_DATE" WHEN 2 THEN
           "SOME_DATE" WHEN 3 THEN "SOME_DATE" WHEN 4 THEN "SOME_DATE" END  IS NOT
           NULL))
modified version where we prevent the MIN function from being applied too early, by using ROWNUM
with data as
  select
    case state -- 1st expression
      when 0 then grp_id
      when 1 then grp_id
      when 2 then grp_id
      when 3 then grp_id
      when 4 then grp_id
    end as grp_id,
    case state --second expression
          when 0 then some_date
          when 1 then some_date
          when 2 then some_date
          when 3 then some_date
          when 4 then some_date
    end as mintime
  from t
  where
    case state --1st expression: at least one index column has to be not null
      when 0 then grp_id
      when 1 then grp_id
      when 2 then grp_id
      when 3 then grp_id
      when 4 then grp_id
    end is not null
  and
    case state --second expression
          when 0 then some_date
          when 1 then some_date
          when 2 then some_date
          when 3 then some_date
          when 4 then some_date
    end is not null 
  and rownum > 0
select--+ GATHER_PLAN_STATISTICS
  grp_id,
  min(mintime)
from data
group by grp_id;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL, NULL, 'allstats  +peeked_binds'));
| Id  | Operation           | Name        | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
|   1 |  HASH GROUP BY           |            |      2 |     20 |     40 |00:00:00.01 |      18 |
|   2 |   VIEW                |            |      2 |     33 |   4000 |00:00:00.07 |      18 |
|   3 |    COUNT           |            |      2 |      |   4000 |00:00:00.05 |      18 |
|*  4 |     FILTER           |            |      2 |      |   4000 |00:00:00.03 |      18 |
|*  5 |      INDEX FAST FULL SCAN| FIDX_ACTIVE |      2 |     33 |   4000 |00:00:00.01 |      18 |
Predicate Information (identified by operation id):
   4 - filter(ROWNUM>0)
   5 - filter(("T"."SYS_NC00006$" IS NOT NULL AND "T"."SYS_NC00007$" IS NOT NULL))

Similar Messages

  • Why does not  a query go by index but FULL TABLE SCAN

    I have two tables;
    table 1 has 1400 rwos and more than 30 columns , one of them is named as 'site_code' , a index was created on this column;
    table 2 has more 150 rows than 20 column , this primary key is 'site_code' also.
    the two tables were analysed by dbms_stats.gather_table()...
    when I run the explain for the 2 sqls below:
    select * from table1 where site_code='XXXXXXXXXX';
    select * from table1 where site_code='XXXXXXXXXX';
    certainly the oracle explain report show that 'Index scan'
    but the problem raised that
    I try to explain the sql
    select *
    from table1,table2
    where 1.'site_code'=2.'site_code'
    the explain report that :
    select .....
    FULL Table1 Scan
    FULL Table2 Scan
    why......

    Nikolay Ivankin  wrote:
    BluShadow wrote:
    Nikolay Ivankin  wrote:
    Try to use hint, but I really doubt it will be faster.No, using hints should only be advised when investigating an issue, not recommended for production code, as it assumes that, as a developer, you know better than the Oracle Optimizer how the data is distributed in the data files, and how the data is going to grow and change over time, and how best to access that data for performance etc.Yes, you are absolutly right. But aren't we performing such an investigation, are we? ;-)The way you wrote it, made it sound that a hint would be the solution, not just something for investigation.
    select * from .. always performs full scan, so limit your query.No, select * will not always perform a full scan, that's just selecting all the columns.
    A select without a where clause or that has a where clause that has low selectivity will result in full table scans.But this is what I have ment.But not what you said.

  • Why isn't my query using the index?

    I have a query that inserts values for engines in a grid; it uses a static date table to determine the day in week, or
    week in year (depending on different standards, the DBA can configure this table to their business's likings). I have
    two indexes on this table:
    create table d_date (
         date_key number(5) not null,
         sql_calendar_date timestamp(3) null,
         year_id number(5) null,
         month_id number(3) null,
         day_id number(3) null,
         year_end_biz_date timestamp(3) null,
         qtr_end_biz_date timestamp(3) null,
         month_end_biz_date timestamp(3) null,
         week_end_biz_date timestamp(3) null,
         quarter_id number(3) null,
         week_id number(3) null,
         day_in_year number(5) null,
         day_in_month number(3) null,
         day_in_week number(3) null,
         month_name char(3) null,
         day_in_week_name char(3) null,
         month_type_code char(1) null,
         week_type_code char(1) null,
         date_type_code char(1) null,
         weekend_flag char(1) null,
         holiday_flag char(1) null,
         from_datetime timestamp(3) null,
         to_datetime timestamp(3) null,
         current_flag char(1) null,
         constraint d_date_pkey primary key (date_key)
         ) tablespace dim;
    create index d_date_dy on d_date(year_id, day_in_year) tablespace_dim_idx;
    create index d_date_ww on d_date(year_id, week_id) tablespace_dim_idx;Now, when I run a query to insert the week id into a table based on two values, the year_key and day_in_year_key,
    it should use the d_date_dy index correct?
    Here is what the query looks like:
    INSERT INTO F_ENGINE (YEAR_KEY,MONTH_KEY,WEEK_IN_YEAR_KEY,DAY_IN_YEAR_KEY,DAY_IN_MONTH_KEY,HOUR_IN_DAY_KEY, Q_HOUR_IN_DAY_KEY,
      GRID_KEY,ENGINE_KEY,TIME_STAMP,ENGINE_CPU_UTIL,ENGINE_CPU_GRID_UTIL,MEMORY_TOTAL_BYTE, MEMORY_FREE_BYTE,DISK_FREE_MEGABYTE,
      PROCESS_COUNT,ENGINE_ID,GRID_ID,GRID_NAME,BATCH_ID,RECORD_VIEWABLE_F)
    SELECT EXTRACT(YEAR FROM START_DATETIME),EXTRACT(MONTH FROM START_DATETIME), DD.WEEK_ID,
      TO_NUMBER(TO_CHAR(START_DATETIME, 'DDD')), EXTRACT(DAY FROM START_DATETIME),EXTRACT(HOUR FROM START_DATETIME),
      FLOOR(EXTRACT(MINUTE FROM START_DATETIME)/15)*15,DG.GRID_KEY,DE.ENGINE_KEY, START_DATETIME,CPU_UTIL,DS_CPU,MEMORY,
      FREE_MEMORY,FREE_DISK,PROCESSES,ID,PE.GRID,DG.GRID_NAME,:B1 ,1
    FROM P_ENGINE PE, D_GRID DG, D_ENGINE DE, D_DATE DD
    WHERE PE.GRID = DG.GRID_ID AND DG.CURRENT_FLAG = 'Y' AND PE.ID = DE.ENGINE_ID AND DE.GRID_KEY = DG.GRID_KEY AND
      DE.CURRENT_FLAG = 'Y' AND PE.BATCH_ID = :B1 AND DD.YEAR_ID = EXTRACT(YEAR FROM START_DATETIME) AND
    DD.DAY_IN_YEAR = TO_NUMBER(TO_CHAR(START_DATETIME,'DDD'))
    ORDER BY EXTRACT(YEAR FROM START_DATETIME),EXTRACT(MONTH FROM START_DATETIME),
      EXTRACT(DAY FROM START_DATETIME),EXTRACT(HOUR FROM START_DATETIME),FLOOR(EXTRACT(MINUTE FROM START_DATETIME)/15)*15,
      DG.GRID_KEY,DE.ENGINE_KEY
    Here is the explain plan:
    Operation Object Object Type Order Rows Size (KB) Cost Time (sec) CPU Cost I/O Cost
    INSERT STATEMENT
    SORT ORDER BY
         HASH JOIN
           HASH JOIN
             HASH JOIN
              TABLE ACCESS FULL D_GRID TABLE 1 2 0.316 3 1 36887 3
              TABLE ACCESS FULL D_ENGINE TABLE 2 10 0.410 3 1 42607 3
             PARTITION LIST SINGLE   5 1434 344.496 9 1 2176890 9
              TABLE ACCESS FULL P_ENGINE TABLE 4 1434 344.496 9 1 2176890 9
                TABLE ACCESS FULL D_DATE TABLE 7 7445 283.550 19 1 3274515 18Now it is obviously not using the index for the d_date table since it is doing a full table access.
    Does this have something to do with the fact that I am using extract(), to_number(), to_char() functions in my WHERE clause that it is not allowing the use of the index?
    Any help would be greatly appreciated. Thanks.
    -Tim

    It's difficult to tell just from this. For one thing, you didn't post your query using the forum format tags, so it's hard to read and you didn't post your Oracle version.
    In the query, you don't always prefix columns with the table alias. That makes it impossible for us (and maintainers of this code) to know at a glance which table a column is in.
    It's possible that performing functions on a column will disable the index. Do your other tables have indexes? Do you have updated statistics on all the tables?
    The main reason the optimizer will not use an index is because it thinks it cheaper not to.

  • HT4641 Im trying to print off my cv, page 1 prints off fine but page 2 does not, I'm using the selected template for curriculum vitae why does my page 2 not print?

    Im trying to print off my cv, page 1 prints off fine but page 2 does not, I'm using the selected template for curriculum vitae why does my page 2 not print?

    Hi @kots 
    I suspect your question would be better answered in the HP Enterprise Business Community, as your HP Printer is a commercial model.
    My technical expertise is with consumer products and software, I am sure the commercial folks would be happy to help if you re-post your question for them to answer. The HP Enterprise Business Community is an HP Forum designed for the Commercial and Enterprise customers to help one another. I am sure you will find some HP folks there to help too.
    Click here to view the Printing and Digital Imaging. When the page opens you will see the option to 'Log in' or 'Register Now' on the right. The commercial forums are separate from the consumer boards, thus you will need to register if you don't already have a commercial account.
    You may find the HP LaserJet M2727 Multifunction Printer series page helpful while you wait for somebody in the commercial Forum to respond to your inquiry.
    Best of luck.
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

  • I have just put a link to my web site but it does not appear while using Firefox but it does if using Internet explorer or Chrome why would this be?

    I am using Window 7 I have just put a link to my web site but it does not appear while using Firefox but it does if using Internet explorer or Chrome why would this be?
    It does appear on a friend's computer using Firefox.
    Barossa Vintage Festival ... this is the missing link on my computer just under the link named ... Autumn photo collection

    No problems here with the tree links:
    View photos
    Friends gather for breakfast
    Friends take an Autumn drive
    Photos of the Barossa Festival
    Reload the web page and bypass the cache.
    * Press and hold Shift and left-click the Reload button.
    * Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    * Press "Cmd + Shift + R" (MAC)

  • Why does not connect properly macpro my motorola bluetooth headphones S10? I get a connection error message and there is no sound. (I want to use headphones to listen to music via bluetooth from my macpro)

    Why does not connect properly macpro my motorola bluetooth headphones S10?     I get a connection error message and there is no sound.                         (I want to use headphones to listen to music via bluetooth from my macpro)   
    the s10 works perfectly on my ipod touch 4g. 

    this is   
    ERROR HAS OCCURRED Bluetooth audio.
    It failed to establish connection with their
    audio device. make sure it is on and
    in the range. you may need to restart the
      audio section of the program you were using
    STOP USING THE HEADSET WITH MICROPHONE.
    ALSO HAVE A MOTOROLA BLUETOOTH SPEAKERS WHICH EQ5 work seamlessly with the Mac

  • Why does not ipad show on itunes? when i connected with my macbook using usb, just it is charging electricity.

    why does not ipad show on itunes? when i connected with my macbook using usb, just it is charging electricity.
    i don't know why...

    Sometimes it can be something very simple and easy to fix. Before you get into any involved troubleshooting, quit iTunes, restart your Mac, restart your iPad and then try to sync again.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    If this doesn't work, then try the more involved stuff.

  • SQLite encrypted Database does not get attached Using Adobe Air,Why?

    Hi,
    Any one knows the solution, am trying to attach the encrypted SQLite database adobe air-adobe flex bulder , it does not get attached using sqlconnection.attach throws error, though the given key is correct, but it gets open using sqlconnection.open with the same key, any one knows the solution, how to attach the encrypted data base, since am using two data base one is opened and another must be attached to the existing ,thanks in advance. using adobe air- flex related. i use the following code
                   databaseFile1 = File.applicationStorageDirectory.resolvePath("Sample_1.sqlite");
                   databaseFile2 = File.applicationStorageDirectory.resolvePath("Sample_2.sqlite");
    dbConnection.open(databaseFile1, SQLMode.CREATE, false, 1024, secKey);
    dbConnection.attach("db2",databaseFile2,null,secKey);
    got the following error.
    ERROR #3125 Unable to open the database file.

    And I would say more "this is the issue" !
    It should be possible as it is clearly stated in the doc :
    public function attach(name:String, reference:Object = null, responder:Responder = null, encryptionKey:ByteArray = null):void
    with 
    encryptionKey:ByteArray (default = null) — The encryption key for the database file. If the attach() call creates a database, the database is encrypted and the specified key is used as the encryption key for the database. If the call attaches an existing encrypted database, the value must match the database's encryption key or an error occurs. If the database being attached is not encrypted, or to create an unencrypted database, the value must be null (the default).
    so with a same encryptionkey, I (and this should be the same for FinalTarget) can open the encrypted db but not to attach it... quite strange.

  • Why is the Star Transformation using two indexes for the same dimension?

    Hi,
    Recently, I have made an investigation about the Star Transformation feature. I have found a strange test case, which plays an important role in my strategy for our overall DWH architecture. Here it is:
    The Strategy:
    I would like to have the classical Star Transformation approach (single column Bitmap Indexes for each dimension foreign key column in the fact table), together with additional Bitmap Join Indexes for some of the dimension attributes, which would benefit from the materialization of the join (bitmap merge operation will be skipped/optimized).
    The query:
    select dp.brand, ds. region_name, dc.region_name
         , count(*), sum(f.extended_price)
      from fact_line_item  f
         , dim_part       dp
         , dim_supplier   ds
         , dim_customer   dc
    where dp.mfgr        = 10                 -- dimension selectivity = 1/10 --> acttual/fact selectivity = 6/10
       and f.part_dk      = dp.dk
       and ds.region_name = 'REGION #1' -- dimension selectivity = 1/9
       and f.supplier_dk  = ds.dk
       and dc.region_name = 'REGION #1' -- dimension selectivity = 1/11
       and f.customer_dk  = dc.dk
    group by dp.brand, ds. region_name, dc.region_name
    The actual plan:
    | Id  | Operation                              | Name                        | Starts | E-Rows | Cost (%CPU)| A-Rows |   A-Time   | Buffers | Reads  |
    |   0 | SELECT STATEMENT                       |                             |      1 |        |  3247 (100)|      1 |00:01:42.05 |     264K|    220K|
    |   1 |  HASH GROUP BY                         |                             |      1 |      2 |  3247   (1)|      1 |00:01:42.05 |     264K|    220K|
    |*  2 |   HASH JOIN                            |                             |      1 |  33242 |  3037   (1)|    217K|00:01:29.67 |     264K|    220K|
    |*  3 |    TABLE ACCESS FULL                   | DIM_SUPPLIER                |      1 |   1112 |   102   (0)|   1112 |00:00:00.01 |     316 |      4 |
    |*  4 |    HASH JOIN                           |                             |      1 |  33245 |  2934   (1)|    217K|00:01:29.10 |     264K|    220K|
    |*  5 |     TABLE ACCESS FULL                  | DIM_CUSTOMER                |      1 |    910 |   102   (0)|    910 |00:00:00.08 |     316 |      8 |
    |*  6 |     HASH JOIN                          |                             |      1 |  33248 |  2831   (1)|    217K|00:01:28.57 |     264K|    220K|
    |*  7 |      TABLE ACCESS FULL                 | DIM_PART                    |      1 |     10 |     3   (0)|     10 |00:00:00.01 |       6 |      0 |
    |   8 |      PARTITION RANGE ALL               |                             |      1 |  36211 |  2827   (1)|    217K|00:01:28.01 |     264K|    220K|
    |   9 |       TABLE ACCESS BY LOCAL INDEX ROWID| FACT_LINE_ITEM              |      6 |  36211 |  2827   (1)|    217K|00:01:33.85 |     264K|    220K|
    |  10 |        BITMAP CONVERSION TO ROWIDS     |                             |      6 |        |            |    217K|00:00:07.09 |   46980 |   3292 |
    |  11 |         BITMAP AND                     |                             |      6 |        |            |     69 |00:00:08.33 |   46980 |   3292 |
    |  12 |          BITMAP MERGE                  |                             |      6 |        |            |    193 |00:00:02.09 |    2408 |   1795 |
    |  13 |           BITMAP KEY ITERATION         |                             |      6 |        |            |   4330 |00:00:04.66 |    2408 |   1795 |
    |  14 |            BUFFER SORT                 |                             |      6 |        |            |     60 |00:00:00.01 |       6 |      0 |
    |* 15 |             TABLE ACCESS FULL          | DIM_PART                    |      1 |     10 |     3   (0)|     10 |00:00:00.01 |       6 |      0 |
    |* 16 |            BITMAP INDEX RANGE SCAN     | FACT_LI__P_PART_DIM_KEY_BIX |     60 |        |            |   4330 |00:00:02.11 |    2402 |   1795 |
    |* 17 |          BITMAP INDEX SINGLE VALUE     | FACT_LI__P_PART_MFGR_BJX    |      6 |        |            |   1747 |00:00:06.65 |     890 |    888 |
    |  18 |          BITMAP MERGE                  |                             |      6 |        |            |    169 |00:00:02.78 |   16695 |    237 |
    |  19 |           BITMAP KEY ITERATION         |                             |      6 |        |            |   5460 |00:00:01.56 |   16695 |    237 |
    |  20 |            BUFFER SORT                 |                             |      6 |        |            |   5460 |00:00:00.02 |     316 |      0 |
    |* 21 |             TABLE ACCESS FULL          | DIM_CUSTOMER                |      1 |    910 |   102   (0)|    910 |00:00:00.01 |     316 |      0 |
    |* 22 |            BITMAP INDEX RANGE SCAN     | FACT_LI__P_CUST_DIM_KEY_BIX |   5460 |        |            |   5460 |00:00:02.07 |   16379 |    237 |
    |  23 |          BITMAP MERGE                  |                             |      6 |        |            |    170 |00:00:03.65 |   26987 |    372 |
    |  24 |           BITMAP KEY ITERATION         |                             |      6 |        |            |   6672 |00:00:02.23 |   26987 |    372 |
    |  25 |            BUFFER SORT                 |                             |      6 |        |            |   6672 |00:00:00.01 |     316 |      0 |
    |* 26 |             TABLE ACCESS FULL          | DIM_SUPPLIER                |      1 |   1112 |   102   (0)|   1112 |00:00:00.01 |     316 |      0 |
    |* 27 |            BITMAP INDEX RANGE SCAN     | FACT_LI__S_SUPP_DIM_KEY_BIX |   6672 |        |            |   6672 |00:00:02.74 |   26671 |    372 |
    The Question:
    Why is the Star Transformation using both indexes FACT_LI__P_PART_DIM_KEY_BIX and FACT_LI__P_PART_MFGR_BJX for the same dimension criteria (dp.mfgr = 10)?? The introduction of the additional Bitmap Join Index actually make Oracle to do the work twice !!!
    Anybody, any idea ?!?

    Dom, here it is the plan with the predicates:
    | Id  | Operation                              | Name                        | Starts | E-Rows | Cost (%CPU)| A-Rows |   A-Time   | Buffers | Reads  |
    |   0 | SELECT STATEMENT                       |                             |      1 |        |  3638 (100)|      1 |00:06:41.17 |     445K|    236K|
    |   1 |  HASH GROUP BY                         |                             |      1 |      2 |  3638   (1)|      1 |00:06:41.17 |     445K|    236K|
    |*  2 |   HASH JOIN                            |                             |      1 |  33242 |  3429   (1)|    217K|00:08:18.02 |     445K|    236K|
    |*  3 |    TABLE ACCESS FULL                   | DIM_SUPPLIER                |      1 |   1112 |   102   (0)|   1112 |00:00:00.03 |     319 |    313 |
    |*  4 |    HASH JOIN                           |                             |      1 |  33245 |  3326   (1)|    217K|00:08:17.47 |     445K|    236K|
    |*  5 |     TABLE ACCESS FULL                  | DIM_CUSTOMER                |      1 |    910 |   102   (0)|    910 |00:00:00.01 |     319 |    313 |
    |*  6 |     HASH JOIN                          |                             |      1 |  33248 |  3223   (1)|    217K|00:08:16.63 |     445K|    236K|
    |*  7 |      TABLE ACCESS FULL                 | DIM_PART                    |      1 |     10 |     3   (0)|     10 |00:00:00.01 |       6 |      0 |
    |   8 |      PARTITION RANGE ALL               |                             |      1 |  36211 |  3219   (1)|    217K|00:08:16.30 |     445K|    236K|
    |   9 |       TABLE ACCESS BY LOCAL INDEX ROWID| FACT_LINE_ITEM              |      6 |  36211 |  3219   (1)|    217K|00:08:40.89 |     445K|    236K|
    |  10 |        BITMAP CONVERSION TO ROWIDS     |                             |      6 |        |            |    217K|00:00:32.00 |   46919 |  19331 |
    |  11 |         BITMAP AND                     |                             |      6 |        |            |     69 |00:00:34.50 |   46919 |  19331 |
    |  12 |          BITMAP MERGE                  |                             |      6 |        |            |    193 |00:00:00.58 |    2353 |      1 |
    |  13 |           BITMAP KEY ITERATION         |                             |      6 |        |            |   4330 |00:00:00.10 |    2353 |      1 |
    |  14 |            BUFFER SORT                 |                             |      6 |        |            |     60 |00:00:00.01 |       6 |      0 |
    |* 15 |             TABLE ACCESS FULL          | DIM_PART                    |      1 |     10 |     3   (0)|     10 |00:00:00.01 |       6 |      0 |
    |* 16 |            BITMAP INDEX RANGE SCAN     | FACT_LI__P_PART_DIM_KEY_BIX |     60 |        |            |   4330 |00:00:00.07 |    2347 |      1 |
    |* 17 |          BITMAP INDEX SINGLE VALUE     | FACT_LI__P_PART_MFGR_BJX    |      6 |        |            |   1747 |00:01:23.64 |     882 |    565 |
    |  18 |          BITMAP MERGE                  |                             |      6 |        |            |    169 |00:00:09.14 |   16697 |   7628 |
    |  19 |           BITMAP KEY ITERATION         |                             |      6 |        |            |   5460 |00:00:02.19 |   16697 |   7628 |
    |  20 |            BUFFER SORT                 |                             |      6 |        |            |   5460 |00:00:00.01 |     316 |      0 |
    |* 21 |             TABLE ACCESS FULL          | DIM_CUSTOMER                |      1 |    910 |   102   (0)|    910 |00:00:00.01 |     316 |      0 |
    |* 22 |            BITMAP INDEX RANGE SCAN     | FACT_LI__P_CUST_DIM_KEY_BIX |   5460 |        |            |   5460 |00:00:08.78 |   16381 |   7628 |
    |  23 |          BITMAP MERGE                  |                             |      6 |        |            |    170 |00:00:21.46 |   26987 |  11137 |
    |  24 |           BITMAP KEY ITERATION         |                             |      6 |        |            |   6672 |00:00:10.29 |   26987 |  11137 |
    |  25 |            BUFFER SORT                 |                             |      6 |        |            |   6672 |00:00:00.01 |     316 |      0 |
    |* 26 |             TABLE ACCESS FULL          | DIM_SUPPLIER                |      1 |   1112 |   102   (0)|   1112 |00:00:00.01 |     316 |      0 |
    |* 27 |            BITMAP INDEX RANGE SCAN     | FACT_LI__S_SUPP_DIM_KEY_BIX |   6672 |        |            |   6672 |00:00:20.94 |   26671 |  11137 |
    Predicate Information (identified by operation id):                                                                                                  
       2 - access("F"."SUPPLIER_DK"="DS"."DK")                                                                                                           
       3 - filter("DS"."REGION_NAME"='REGION #1')                                                                                                        
       4 - access("F"."CUSTOMER_DK"="DC"."DK")                                                                                                           
       5 - filter("DC"."REGION_NAME"='REGION #1')                                                                                                        
       6 - access("F"."PART_DK"="DP"."DK")                                                                                                               
       7 - filter("DP"."MFGR"=10)                                                                                                                        
      15 - filter("DP"."MFGR"=10)                                                                                                                        
      16 - access("F"."PART_DK"="DP"."DK")                                                                                                               
      17 - access("F"."SYS_NC00017$"=10)                                                                                                                 
      21 - filter("DC"."REGION_NAME"='REGION #1')                                                                                                        
      22 - access("F"."CUSTOMER_DK"="DC"."DK")                                                                                                           
      26 - filter("DS"."REGION_NAME"='REGION #1')                                                                                                        
      27 - access("F"."SUPPLIER_DK"="DS"."DK")                                                                                                           
    Note                                                                                                                                                 
       - star transformation used for this statement                                                                                                     

  • Does an 'in' clause use the index?

    In the following query:
    Select * from myTable where field_1 in ('thisfield', 'thatfield');
    Assuming there is an index on field_1, will this query use the index?
    Thanks,
    Sara

    In the following query:
    Select * from myTable where field_1 in ('thisfield', 'thatfield');
    Assuming there is an index on field_1, will this query use the index?It should use the index to find where the row you want is in the table and then access the table to return all colunms for that row.
    This can be easily verified by doing an explain plan on your SQL statement. The Oracle manuals should have information on how to
    run an explain plan if you're not familiar with it.

  • Peformance tuning of query using bitmap indexes

    Hello guys
    I just have a quick question about tuning the performance of sql query using bitmap indexes..
    Currently, there are 2 tables, date and fact. Fact table has about 1 billion row and date dim has about 1 million. These 2 tables are joined by 2 columns:
    Date.Dateid = Fact.snapshot.dates and Date.companyid = fact.companynumber
    I have query that needs to be run as the following:
    Select dates.dayofweek, dates,dates, fact.opened_amount from dates, facts
    where Date.Dateid = Fact.snapshot.dates and Date.companyid = fact.companynumber and dates.dayofweek = 'monday'.
    Currently this query is running forever. I think it is joining that takes a lot of time. I have created bitmap index on dayofweek column because it's low on distinctive rows. But it didn't seem to speed up with the performance..
    I'd like to know what other indexes will be helpful for me.. I am thinking of creating another one for companynumber since it also have low distinctive records.
    Currently the query is being generated by frontend tools like OBIEE so I can't change the sql nor can't I purge data or create smaller table, I have to what with what I have..
    So please let me know your thoughts in terms of performance tunings.
    Thanks

    The explain plan is:
    Row cost Bytes
    Select statement optimizer 1 1
    nested loops 1 1 299
    partition list all 1 0 266
    index full scan RD_T.PK_FACTS_SNPSH 1 0 266
    TABLE ACCESS BY INDEX ROWID DATES_DIM 1 1 33
    INDEX UNIQUE SCAN DATES_DIM_DATE 1 1
    There is no changes nor wait states, but query is taking 18 mins to return results. When it does, it returns 1 billion rows, which is the same number of rows of the fact table....(strange?)That's not a bitmap plan. Plans using bitmaps should have steps indicating bitmap conversions; this plan is listing ordinary btree index access. The rows and bytes on the plan for the volume of data you suggested have to be incorrect. (1 row instead of 1B?????)
    What version of the data base are you using?
    What is your partition key?
    Are the partioned table indexes global or local? Is the partition key part of the join columns, and is it indexed?
    Analyze the tables and all indexes (use dbms_stats) and see if the statistics get better. If that doesn't work try the dynamic sampling hint (there is some overhead for this) to get statistics at runtime.
    I have seen stats like the ones you listed appear in 10g myself.
    Edited by: riedelme on Oct 30, 2009 10:37 AM

  • Is there a way to increase the icon size (and the text below) without using zoom?  I am trying to help out someone who has moderate visual impairment that does not want to use zoom just to see the icons and their labels.

    Is there a way to increase the icon size (and the text below) without using zoom in iOS 7?  I am trying to help out someone who has moderate visual impairment that does not want to use zoom just to see the icons and their labels.

    Hello Apple.
    It seems you have gone to great lengths to improve accessibility in many areas of the iPad. Why was this obvious problem with icon text size missed?  (It's not with the Mac.). And for so long too.
    Do you employ people with actual accessibility problems to help you do UI design?
    I think too, that some buttons are too close for people who might have motor control problems.
    I love my iPad but I fear as I age, the iPad might not keep up with me.

  • Server does not return query metadata check the query

    hi,
    i want know how to  use bex query designer,
    when i  insert a data provider,the message is appear "server does not return query metadata check the query",
    who can help me ?
    thanks a lot !
    addition: my current entironment is: gui710 with sp4,bi710 with sp2.

    Hi,
    All the yellow and red lights will have an effect on query performance or execution.  Read up on them as there are too many to explain via this forum.
    There is a document on SDN on query performance.  Some useful links:
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9f4a452b-0301-0010-8ca6-ef25a095834a]
    [http://help.sap.com/saphelp_nw70/helpdata/en/41/b987eb1443534ba78a793f4beed9d5/frameset.htm]
    [http://help.sap.com/saphelp_nw70/helpdata/en/d9/31363dc992752de10000000a114084/frameset.htm]
    [http://help.sap.com/saphelp_nw04/helpdata/en/2e/caceae8dd08e48a63c2da60c8ffa5e/frameset.htm]
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e0501cb9-d51c-2a10-239c-c141a22c45a6]
    Cheers...

  • Why does Notes close every time I open it?   I can't access my notes...

    Why does Notes close every time I open it?   I can't access my notes;
    there don't appear to be any.    Help!
    When I check in Settings, Notes has disappeared from the list of Apps
    On my iPhone, yet I didn't delete it.    I had dozens of notes, lots
    of necessary information stored therein. 
    Thanks for any help....

    I was having this issue also. I found this thread and disabling Exchange Notes did the trick. Obviously, this is the solution only if you were using Exchange to begin with.
    If you want to continue to use Exchange notes or perhaps try this to see if it works in general, I found a fix on this site. All works well now.
    1. Delete your exchange account from the Mail, Contacts & Calendars pane in System Preferences.
    2. Go to Finder, click "Go" in the menu bar, click "Go to Folder" and type in "~/Library" (without the quotes) in the box. This will take you to your user Library folder.
    3. Use the search box in the finder and type in "com.apple.notes" and click "Library" in the search bar that appears. This should now find several folders and files related to the Notes app. Rename or delete everything except the help files (with the lifesaver icons on them).
    4. Restart your Mac. Put your exchange account back into System Preferences, you can go ahead and activate the Notes sync service.
    5. Open Notes and it should be working now!

  • I m coming from linux platform ... now need my g   to work with vim ... how to install g   which supports C  0x ... why does  not it has repository with apple ... its so easy rather than going to UI ...

    i m coming from linux platform ... now need my g   to work with vim ... how to install g   which supports C  0x ... why does  not it has repository with apple ... its so easy rather than going to UI ...

    tom i have been using ubuntu for c++ project
    i use lambda and atomic (c++0x) but now as I am working on MAC not able to use them
    installed xcode(4.3) and changed compiler settings to LLVM3.1 but still both features are not available
    to compile wanted to have g++ which supports c++0x features ...
    new to MAC (2-3 days) so was in rush to solution
    let me know if you have some suggestion ...
    else will try with eclipse cdt .... 

Maybe you are looking for