Aggregate Query Optimization (with indexes) for trivial queries

Table myTable, which is quite large, has an index on the month column.
"select max(month) from myTable" uses this index and returns quickly.
"select max(month) from myTable where 1 = 1" does not use this index, falls through to a full table scan, and takes a very long time.
Can this possibly be a genuine omission in the query optimizer, or is there some setting or another to convince it to perform the latter query more sanely?

Oracle 11.2.0.1
SQL> select table_name, num_rows from dba_tables where table_name = 'DWH_ADDRESS_MASTER';
TABLE_NAME                                 NUM_ROWS
DWH_ADDRESS_MASTER                        295729948
SQL> explain plan for select max(last_update_date) from DWH.DWH_ADDRESS_MASTER;
| Id  | Operation                  | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT           |                        |     1 |     8 |     4   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE            |                        |     1 |     8 |            |          |
|   2 |   INDEX FULL SCAN (MIN/MAX)| DWH_ADDRESS_MASTER_N1  |     1 |     8 |     4   (0)| 00:00:01 |
SQL> explain plan for select max(last_update_date) from DWH.DWH_ADDRESS_MASTER where 1 = 1;
| Id  | Operation                   | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT            |                        |     1 |     8 |     4   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE             |                        |     1 |     8 |            |          |
|   2 |   FIRST ROW                 |                        |     1 |     8 |     4   (0)| 00:00:01 |
|   3 |    INDEX FULL SCAN (MIN/MAX)| DWH_ADDRESS_MASTER_N1  |     1 |     8 |     4   (0)| 00:00:01 |
------------------------------------------------------------------------------------------------------

Similar Messages

  • Query Optimization with partitioned/subpartitioned tables

    I have a 1 billion row table with 72 partitions by range and thousands of subpartitions by list. There is a bitmap index on the subpartition by list field.
    If I execute the following query which requests data from a single partition and a single subpartition:
    SQL> select * from cen00_demog_sf1_hp where
    ckey like '33011%' and demogname = 'P002006';
    the optimizer selects a single partition ('33...') and a single subpartition ('P002006'). The query takes only 6 seconds including displaying the 7,386 row result.
    However, if I then execute the following query which selects data from two partitions and a single subpartition within each partition:
    SQL> select * from cen00_demog_sf1_hp where
    (ckey like '33011%' or ckey like '35001%')
    and demogname = 'P002006';
    the optimizer scans all partitions rather than just scanning partitions 33 and 35. The query takes over 10 minutes to display the 17,972 row result. If this query is split into two separate queries, the same result set can be realized in a total 26 seconds including display the results to the screen.
    Any suggestions on how the multiple partition query can be modified to avoid an all rows scan?
    Thank you.

    I had previously tried reversing the WHERE clause statements in the query but it had no affect. The execution plan for the two partition query follows. Note the "ALL" on the partition range. I purposely did not index the ckey field believing that partitioning would be sufficent (ckey contains 8,262,363 unique keys out of 1,041,057,738 rows). As a test a query requesting a demogval based on a single ckey for a particular demogname returns a result in less than a second. Another test requesting data for a particular ckey without a demogname qualifier resulted in a full scan of a single partition (but not all the partitions) taking 4 minutes of elapsed time. Note that the only reason that there is a bitmap index on the demogname in table cen00_demog_sf1_hp is that normally the query is a join with another table containing an indexed demogname field. In sum, it appears that the optimizer defaults to an all partition scan when more than one partition is included in the query.
    Elapsed: 00:11:38.41
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=53824 Card=4 Bytes=148)
    1 0 PARTITION RANGE (ALL) (Cost=53824 Card=4 Bytes=148)
    2 1 PARTITION LIST (SINGLE) (Cost=53824 Card=4 Bytes=148)
    3 2 TABLE ACCESS (BY LOCAL INDEX ROWID) OF 'CEN00_DEMOG_SF1_HP' (TABLE) (Cost=53824 Card=4 Bytes=148)
    4 3 BITMAP CONVERSION (TO ROWIDS)
    5 4 BITMAP INDEX (SINGLE VALUE) OF 'CEN00_DEMOG_SF1_HP_IDX' (INDEX (BITMAP))
    The single partition query trace shows selectivity on the partition range.
    Elapsed: 00:00:09.69
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=42 Card=133 Bytes=4655)
    1 0 PARTITION RANGE (SINGLE) (Cost=42 Card=133 Bytes=4655)
    2 1 PARTITION LIST (SINGLE) (Cost=42 Card=133 Bytes=4655)
    3 2 TABLE ACCESS (BY LOCAL INDEX ROWID) OF 'CEN00_DEMOG_SF1_HP' (TABLE) (Cost=42 Card=133 Bytes=4655)
    4 3 BITMAP CONVERSION (TO ROWIDS)
    5 4 BITMAP INDEX (SINGLE VALUE) OF 'CEN00_DEMOG_SF1_HP_IDX' (INDEX (BITMAP))

  • Text index for UNION queries.

    Hi All,
    Can anyone please help me in tuning search query mentioned below
    select id from usr1.organizations where lower(ID_official_name)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_NORM_NAME)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NAME)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_TRANS_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_TRANS_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_dba_name)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_TRANS_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fka_name)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_TRANS_NAME)   like  'technology%'Here organizations table is the parent table having primary key on id column, and rest all tables are children tables having foreign key on id column referencing to primary key id column in organizations table.
    Planning to implement multiple column(Userdatastore) text index on dummy column appended to organizations table. And write triggers on other child tables to trigger the sync for Text index.
    But not sure whether we can rewrite this above sql query by replacing union into joins, not sure why developer has not done so.
    Can anyone please help me in creating text index for this sql. I do not want to approach cartesian joins as these are having parent-child relationship.
    Oracle Version: 10.2.0.4
    Please let me know if you need more information

    1 .As text index is created in parent table on id column, can we somehow search only from particular columns(Parent or child) by using user_datastore and tags for sectioning it?
    Below are the sql which i need to make use of text index
    select m.id from id_ALIAS_NAMEs an
    join organizations m on(m.id=an.id)
    where lower(ID_ALIAS_NAME)   like  'technology%' and m.id_data_provider<100;
    select M.id,ID_ALIAS_NAME,'ID_ALIAS_NAME' AS NAMETYPE
    from id_alias_names an JOIN organizations m ON m.id=an.id
    where id_data_provider<100 AND coalesce(m.ID_COUNTRY_OF_DOMICILE,m.ID_COUNTRY_OF_INCORPORATION)='US'
    AND LOWER(ID_ALIAS_NAME) like LOWER('TECHNOLOGY%')
    and F_GetFirstWord(ORG_ALIAS_NAME)='TECHNOLOGY'
    The text index must be created on a text column, not a numeric id column. It is common to create it on a dummy column. You can name that column anything you like instead of dummy, like search_columns or some such thing. You can add tags in your procedure, so that your resulting virtual column is like xml data. You can then create a section group, so that you can search within each of those tags. In the example below, I used ctxsys.auto_section_group because it is the simplest to create, but you may get better performance by using another type of section group and naming each individual tag.
    SCOTT@orcl_11gR2> -- tables you already have:
    SCOTT@orcl_11gR2> create table organizations
      2    (id                    number primary key,
      3       id_official_name          varchar2 (10),
      4       id_official_norm_name          varchar2 (10),
      5       id_official_eng_name          varchar2 (10),
      6       id_official_trans_name          varchar2 (10),
      7       id_data_provider          number,
      8       id_country_of_domicile          varchar2 (10),
      9       id_country_of_incorporation  varchar2 (10))
    10  /
    Table created.
    SCOTT@orcl_11gR2> create table id_alias_names
      2    (id                    number references organizations (id),
      3       id_alias_name               varchar2 (10),
      4       id_alias_norm_name          varchar2 (10),
      5       id_alias_eng_name          varchar2 (10),
      6       id_alias_trans_name          varchar2 (10))
      7  /
    Table created.
    SCOTT@orcl_11gR2> create table id_doing_business_as_names
      2    (id                    number references organizations (id),
      3       id_dba_name               varchar2 (10),
      4       id_dba_norm_name          varchar2 (10),
      5       id_dba_eng_name           varchar2 (10),
      6       id_dba_trans_name          varchar2 (10))
      7  /
    Table created.
    SCOTT@orcl_11gR2> create table id_fka_names
      2    (id                    number references organizations (id),
      3       id_fka_name               varchar2 (10),
      4       id_fka_norm_name          varchar2 (10),
      5       id_fka_eng_name           varchar2 (10),
      6       id_fka_trans_name          varchar2 (10))
      7  /
    Table created.
    SCOTT@orcl_11gR2> -- test data:
    SCOTT@orcl_11gR2> insert all
      2  into organizations values (1, 'test', 'name2', 'name3', 'name4', 99, 'US', null)
      3  into organizations values (2, 'name1', 'name2', 'name3', 'name4', 99, null, 'US')
      4  into organizations values (3, 'name1', 'name2', 'name3', 'name4', 99, null, null)
      5  into organizations values (4, 'name1', 'name2', 'name3', 'name4', 101, 'US', 'US')
      6  into organizations values (5, 'technology', 'technology', 'technology', 'technology', 99, 'US', 'US')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> insert all
      2  into id_alias_names values (1, 'technology', 'name6', 'name7', 'name8')
      3  into id_alias_names values (2, 'technology', 'test', 'name7', 'name8')
      4  into id_alias_names values (3, 'technology', 'name6', 'name7', 'name8')
      5  into id_alias_names values (4, 'technology', 'name6', 'name7', 'name8')
      6  into id_alias_names values (5, 'name5', 'technology', 'technology', 'technology')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> insert all
      2  into id_doing_business_as_names values (1, 'name9', 'name10', 'name11', 'name12')
      3  into id_doing_business_as_names values (2, 'name9', 'name10', 'name11', 'name12')
      4  into id_doing_business_as_names values (3, 'name9', 'name10', 'test', 'name12')
      5  into id_doing_business_as_names values (4, 'name9', 'name10', 'name11', 'name12')
      6  into id_doing_business_as_names values (5, 'technology', 'technology', 'technology', 'technology')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> insert all
      2  into id_fka_names values (1, 'name13', 'name14', 'name15', 'name16')
      3  into id_fka_names values (2, 'name13', 'name14', 'name15', 'name16')
      4  into id_fka_names values (3, 'name13', 'name14', 'name15', 'name16')
      5  into id_fka_names values (4, 'name13', 'name14', 'name15', 'test')
      6  into id_fka_names values (5, 'technology', 'technology', 'technology', 'technology')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> -- revised procedure to join tables with tags:
    SCOTT@orcl_11gR2> create or replace procedure your_proc
      2    (p_rowid in           rowid,
      3       p_clob     in out nocopy clob)
      4  as
      5  begin
      6    for r1 in
      7        (select id,
      8             '<id_official_name>'
      9             || id_official_name
    10             || '</id_official_name><id_official_norm_name>'
    11             || id_official_norm_name
    12             || '</id_official_norm_name><id_official_eng_name>'
    13             || id_official_eng_name
    14             || '</id_official_eng_name><id_official_trans_name>'
    15             || id_official_trans_name
    16             || '</id_official_trans_name>' as tags_and_values
    17         from      organizations
    18         where  rowid = p_rowid)
    19    loop
    20        dbms_lob.writeappend
    21          (p_clob, length (r1.tags_and_values), r1.tags_and_values);
    22        for r2 in
    23          (select '<id_alias_name>'
    24               || id_alias_name
    25               || '</id_alias_name><id_alias_norm_name>'
    26               || id_alias_norm_name
    27               || '</id_alias_norm_name><id_alias_eng_name>'
    28               || id_alias_eng_name
    29               || '</id_alias_eng_name><id_alias_trans_name>'
    30               || id_alias_trans_name
    31               || '</id_alias_trans_name>' as tags_and_values
    32           from   id_alias_names
    33           where  id = r1.id)
    34        loop
    35          dbms_lob.writeappend
    36            (p_clob, length (r2.tags_and_values), r2.tags_and_values);
    37        end loop;
    38        for r3 in
    39          (select '<id_dba_name>'
    40               || id_dba_name
    41               || '</id_dba_name><id_dba_norm_name>'
    42               || id_dba_norm_name
    43               || '</id_dba_norm_name><id_dba_eng_name>'
    44               || id_dba_eng_name
    45               || '</id_dba_eng_name><id_dba_trans_name>'
    46               || id_dba_trans_name
    47               || '</id_dba_trans_name>' as tags_and_values
    48           from   id_doing_business_as_names
    49           where  id = r1.id)
    50        loop
    51          dbms_lob.writeappend
    52            (p_clob, length (r3.tags_and_values), r3.tags_and_values);
    53        end loop;
    54        for r4 in
    55          (select '<id_fka_name>'
    56               || id_fka_name
    57               || '</id_fka_name><id_fka_norm_name>'
    58               || id_fka_norm_name
    59               || '</id_fka_norm_name><id_fka_eng_name>'
    60               || id_fka_eng_name
    61               || '</id_fka_eng_name><id_fka_trans_name>'
    62               || id_fka_trans_name
    63               || '</id_fka_trans_name>' as tags_and_values
    64           from   id_fka_names
    65           where  id = r1.id)
    66        loop
    67          dbms_lob.writeappend
    68            (p_clob, length (r4.tags_and_values), r4.tags_and_values);
    69        end loop;
    70    end loop;
    71  end your_proc;
    72  /
    Procedure created.
    SCOTT@orcl_11gR2> show errors
    No errors.
    SCOTT@orcl_11gR2> -- examples of virtual columns that revised procedure returns:
    SCOTT@orcl_11gR2> declare
      2    v_clob  clob;
      3  begin
      4    for r in
      5        (select rowid, id
      6         from      organizations)
      7    loop
      8        dbms_lob.createtemporary (v_clob, true);
      9        your_proc (r.rowid, v_clob);
    10        dbms_output.put_line (r.id);
    11        dbms_output.put_line (v_clob);
    12        dbms_lob.freetemporary (v_clob);
    13    end loop;
    14  end;
    15  /
    1
    <id_official_name>test</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name3
    </id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><i
    d_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
    lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
    ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
    ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
    2
    <id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
    3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
    id_alias_norm_name>test</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
    lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
    ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
    ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
    3
    <id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
    3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
    id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
    alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>test</id_db
    a_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_fk
    a_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
    4
    <id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
    3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
    id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
    alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_
    dba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_
    fka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>test</id_fka_trans_name>
    5
    <id_official_name>technology</id_official_name><id_official_norm_name>technology</id_official_norm_name><id_official_eng
    _name>technology</id_official_eng_name><id_official_trans_name>technology</id_official_trans_name><id_alias_name>name5</
    id_alias_name><id_alias_norm_name>technology</id_alias_norm_name><id_alias_eng_name>technology</id_alias_eng_name><id_al
    ias_trans_name>technology</id_alias_trans_name><id_dba_name>technology</id_dba_name><id_dba_norm_name>technology</id_dba
    _norm_name><id_dba_eng_name>technology</id_dba_eng_name><id_dba_trans_name>technology</id_dba_trans_name><id_fka_name>te
    chnology</id_fka_name><id_fka_norm_name>technology</id_fka_norm_name><id_fka_eng_name>technology</id_fka_eng_name><id_fk
    a_trans_name>technology</id_fka_trans_name>
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> -- user_datastore:
    SCOTT@orcl_11gR2> begin
      2    ctx_ddl.create_preference ('your_datastore', 'user_datastore');
      3    ctx_ddl.set_attribute ('your_datastore', 'procedure', 'your_proc');
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> -- dummy column:
    SCOTT@orcl_11gR2> alter table organizations add (dummy varchar2(1))
      2  /
    Table altered.
    SCOTT@orcl_11gR2> -- index with auto_section_group,
    SCOTT@orcl_11gR2> -- must be on a text column, like dummy, not numeric id column:
    SCOTT@orcl_11gR2> create index your_index
      2  on organizations (dummy)
      3  indextype is ctxsys.context
      4  parameters
      5    ('datastore     your_datastore
      6        section group     ctxsys.auto_section_group')
      7  /
    Index created.
    SCOTT@orcl_11gR2> -- example queries:
    SCOTT@orcl_11gR2> select id
      2  from   organizations
      3  where  contains (dummy, 'technology within id_alias_name') > 0
      4  and    id_data_provider < 100
      5  /
            ID
             1
             2
             3
    3 rows selected.
    SCOTT@orcl_11gR2> select m.id, an.id_alias_name, 'ID_ALIAS_NAME' as nametype
      2  from   id_alias_names an join organizations m on m.id = an.id
      3  where  contains (m.dummy, 'technology within id_alias_name') > 0
      4  and    m.id_data_provider < 100
      5  and    coalesce (m.id_country_of_domicile, m.id_country_of_incorporation) = 'US'
      6  /
            ID ID_ALIAS_N NAMETYPE
             1 technology ID_ALIAS_NAME
             2 technology ID_ALIAS_NAME
    2 rows selected.
    SCOTT@orcl_11gR2>

  • Query optimization with multiple 1-M relationships

    Hello,
    I have a simple example of a problem I'm trying to solve. Three tables A, B, C. A is the 'parent' table with a 1-M relationship with B, which then has a 1-M relationship with C. Each of these tables has a corresponding object. I would like to execute one simple query to retrieve a collection of fully populated A objects (each containing a collection of B objects, and each B object containing a collection of C objects).
    The underlying query should be something like this:
    select * from A, B, C where B.A_ID = A.A_ID and C.B_ID = B.B_ID;
    Is what I'm trying to do possible? How is this done? My initial attempt yielded an A object for each row in the result set which is incorrect. I tried various combinations of indirection, enabling joining, and batch reading with no luck. Ultimately, I need to retrieve this object graph in as few queries as possible (ideally just one).
    Thanks in advance for any help.
    -Jeff

    Thanks for your reply King.
    I'm still not able to get this to work. It's executing two SQL statements:
    1) SELECT A2, A_ID, A1 FROM A
    2) SELECT t0.B2, t0.A_ID, t0.B_ID, t0.B1 FROM B t0, A t1 WHERE (t0.A_ID = t1.A_ID)
    I'm running TopLink 903 (build 425). The thing that concerns me is that it's not even populating the B object (but that second SQL statement does return 3 rows).
    I've tried reading with a named query (with the 3 table join query posted previously) and with session.readAllObjects(A.class). A has a 1-M relationship to B with batch reading and transparent indirection turned on. B then has the same setup with C.
    Does it matter how my foreign keys are set up? Does it matter how the database references are set up?
    I'll keep digging. Any further assistance you can provide would be appreciated.
    Thanks again,
    -Jeff

  • Query registry with powershell for certain value

    Hi,
    Ever since Windows 7 we are having trouble with USB-printers. For some reason they get disabled ever so often.
    The only solution we have then, (that works) is to fully remove and re-install the device.
    However, we give our printer a specific name "loketprinter". If you remove the printer, some values with "Loketprinter" remains in the registry. These are located in various locations troughout the registry.
    Therefore i'm looking for a fast way to query and delete values or keys that contain "loketcomputer".
    I want to search the whole register.
    Could you please get me on my way?

    after some googeling and reading the help file i've created the following: 
    Get-ChildItem HKCU:, HKLM: -Recurse -Include *Loket* -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name
    This only find parts of it, but at least its something.
    Its really slow though

  • Query works with indexs but view does not

    Hi,
    I am using the following query:
    SQL> select t.xml_msg_text
    2 from xml_tbl t
    3 where xmlexists (
    4 'declare namespace ns1 = "Abc:SET"; fn:collection("oradb:/DEV/TABLE1")/ROW[ID1=$d/main/ns1:id]'
    5 passing t.xml_msg_text as "d"
    6 );
    It gets executed very fast as it uses the underlying XMLType indexes.
    But if I create a view usign this query. And then Select * from View_Name. It does not use the indexes and takes forever to execute.
    Any suggestions please.
    Thanks..

    Actually I can't create the Explain Plan for this in SqlPlus:
    In the following query:
    select t.xml_msg_text
    from xml_tbl t
    where xmlexists (
    'declare namespace ns1 = "Abc:SET"; fn:collection("oradb:/DEV/TABLE1")/ROW[ID1=$d/main/ns1:id]'
    passing t.xml_msg_text as "d"
    WHEREAS
    I can create the Explain Plan for
    select t.xml_msg_text
    from xml_tbl t
    - There is XQuery Code
    - And TABLE1 is in another schema but I have created the synonym and given the proper rights. That's why I can execute the query but can't see the plan in SQL Plus.
    Please suggest.
    Thanks..

  • PP/DS Optimizer u2013 Planning for HALB and FERT in sequence with Optimizer

    We are using PP/DS optimizer to plan the two level BOM items. FERT and HALB planned orders are converted from SNP. ROH products are not planned in APO. PPDS is not used to create or delete orders. Only scheduling is done by optimizer. Only one mode exists in PDS. Setup matrix is used for both HALB and FERT.
    The requirement is to schedule HALB products in time on their own resources in time for multiple FERT orders. The optimizer does not appear to do this consistently. We use the following steps in planning run:
    1.     Stage numbering.
    2.     Schedule orders at the earliest with infinite planning. This is done to ensure there are no blank spaces at the beginning of the planning interval on resources after optimization. The result is all orders starting at the same time with multiple loading on resources.
    3.     Optimization with weightage for makespan and setup time. Key settings are: Forward planning, finite resource loading, pegging relevance, considering inter order relationships. All HALB and FERT resources are selected in this step. (Delays are not important within the Optimization interval and there are no stocks of HALB except when there are time gaps between HALB Orders and FERT orders. HALB order is finished earier than FERT order start.)
    The question is: Is Optimizer capable of scheduling HALB and FERT on their own resources  but at the right iner order timings while optimizing the setup time. Are there any key setting to watch out for in Optimization profile or Strategy profile to enable this?
    If this is not possible, we will have optimize only at one BOM level and then use top down or bottom up heuristics to plan the other level.

    HI TemYogi,
    Assumptions:
    1. One PDS each for HALB & FERT level with one resource
    2. HALB to be scheduled first. Based on HALB schedule, FERT has to be scheduled
    To achieve this
    Maintain "Maximum Lateness of a Receipt"  in Pegging tab in Demand tab in Product master
    in FERT PDS maintain the consumption type of HALB components as continious/ start/end of the the operation
    use the planning direction as backward and reverse in DS strategy profile
    Use schedule mode as Insert operation / insert operation and close gaps until end in DS strategy profile
    Fix all the previous run orders in DS board for HALB and then Schedule all the HALB orders considering u r setups through optimization
    Now run the optimizer for FERT
    Regards
    Sravan maturu
    +91 9392602314

  • Indexing for Load efficiency or Query Efficiency

    Hello,
    I've just come to start querying our warehouse which is currently being developed. Unfortunately, although the tables and indexes were spec'd at the design for query performance, the ETL team loading the table have set up indexes to improve load efficiency.
    Is there anyway of placing 2 sets of indexes on a table, one for the load process and one for querying? Or should the queries be done on materialised views?
    Any help would be much appreciated.
    Regards
    James

    Just to clarify, there may be a harm in having multiple sets of indexes since index maintenance may consume a significant fraction of the ETL time. If the goal is to optimize the load, you may want to drop and rebuild the indexes that exist for query performance (assuming that queries and loads run during separate windows). Depending on volumes and load characteristics, I could envision scenarios where you could drop the indexes used by consumers, build the indexes for ETL, run the ETL, drop the ETL indexes, and rebuild the consumer indexes, but that would be rather rare.
    Materialized views can certainly come into play to satisfy warehouse queries, particular for aggregate data. It wouldn't make much sense to drop indexes on base tables and create them on materialized views that were exact copies of those base tables since that wouldn't save you any processing time. If your MV's have sigificantly fewer rows than the base tables, though, indexes on the aggregates may be significantly cheaper to maintain.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Can Oracle be forced to use the spatial index for sdo_filter in combination with an or clause? Difference between Enterprise and SE?

    We’re seeing the following issue: sql - Can Oracle be forced to use the spatial index for sdo_filter in combination with an or clause? - Stack Overflow (posted by a colleague of mine) and are curious to know if this behaviour is due to a difference between standard and enterprise, or could we doing something else wrong in our DB config.?
    We have also reproduced the issue on the following stacks:
    Oracle SE One 11.2.0.3 (with Spatial enabled)
    Redhat Linux 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
    11.2.0.3.0 Standard Edition and 11.2.0.4.0 Standard Edition (both with Spatial enabled)
    Microsoft Windows Server 2003R2 Standard x64 Edition
    However, the SQL works fine if we try it on Oracle 11.2.0.3.0 *Enterprise* Edition.
    Any help or advice would be much appreciated.
    Kindest Regards,
    Kevin

    In my experience sdo_filter ALWAYS uses the spatial index, so that's not the problem. Since you did not provide the explain plans, we can't say for sure but I think yhu is right: Standard Edition can't use the bitmap operations, and thus it'll take longer to combine the results of the two queries (because the optimizer will surely split this OR up in two parts, then combine them).
    BTW: when asking questions about queries here, it would be nice if you posted the queries here as well, so that we do not have to check another website in order to see what you are doing. Plus it will probably get you more answers, because not everyone can be bothered to click on that link. It would also have been nice if you had posted your own answer on the other post here as well, because my recommendation would have been to use union all - but since you already found that out for yourself my recommendation would have been a little late.

  • SQL query performance difference with Index Hint in Oracle 10g

    Hi,
    I was having a problem in SQL select query which was taking around 20 seconds to get the results. So, by hit and trail method I added Index Oracle Hint into the same query with the list of indexes of the tables and the results are retrieved with in 10 milli seconds. I am not sure to get How this is working with Indexes Hint.
    The query with out Index Hint:
    select /*+rule*/ FdnTab2.fdn, paramTab3.attr_name from fdnmappingtable FdnTab, fdnmappingtable FdnTab2, parametertable paramTab1 ,parametertable paramTab3  where FdnTab.id=52787 and paramTab1.id= FdnTab.id  and paramTab3.id = FdnTab.id  and paramTab3.attr_value = FdnTab2.fdn  and paramTab1.attr_name='harqUsersMax' and paramTab1.attr_value <> 'DEFAULT' and exists ( select ParamTab2.attr_name from parametertable ParamTab2, templaterelationtable TemplateTab2  where TemplateTab2.id=FdnTab.id  and ParamTab2.id=TemplateTab2.template_id  and ParamTab2.id=FdnTab2.id  and ParamTab2.attr_name=paramTab1.attr_name)  ==> EXECUTION TIME: 20 secs
    The same query with Index Hint:
    select /*+INDEX(fdnmappingtable[PRIMARY_KY_FDNMAPPINGTABLE],parametertable[PRIMARY_KY_PARAMETERTABLE])*/ FdnTab2.fdn, paramTab3.attr_name from fdnmappingtable FdnTab, fdnmappingtable FdnTab2, parametertable paramTab1 ,parametertable paramTab3 where FdnTab.id=52787 and paramTab1.id= FdnTab.id and paramTab3.id = FdnTab.id and paramTab3.attr_value = FdnTab2.fdn and paramTab1.attr_name='harqUsersMax' and paramTab1.attr_value <> 'DEFAULT' and exists ( select ParamTab2.attr_name from parametertable ParamTab2, templaterelationtable TemplateTab2 where TemplateTab2.id=FdnTab.id and ParamTab2.id=TemplateTab2.template_id and ParamTab2.id=FdnTab2.id and ParamTab2.attr_name=paramTab1.attr_name) ==> EXECUTION TIME: 10 milli secs
    Can any one suggest what could be the real problem?
    Regards,
    Purushotham

    Sorry,
    The right query and the explain plan:
    select /*+rule*/ FdnTab2.fdn, paramTab3.attr_name from fdnmappingtable FdnTab, fdnmappingtable FdnTab2, parametertable paramTab1 ,parametertable paramTab3  where FdnTab.id=52787 and paramTab1.id= FdnTab.id  and paramTab3.id = FdnTab.id  and paramTab3.attr_value = FdnTab2.fdn  and paramTab1.attr_name='harqUsersMax' and paramTab1.attr_value <> 'DEFAULT' and exists ( select ParamTab2.attr_name from parametertable ParamTab2, templaterelationtable TemplateTab2  where TemplateTab2.id=FdnTab.id  and ParamTab2.id=TemplateTab2.template_id  and ParamTab2.id=FdnTab2.id  and ParamTab2.attr_name=paramTab1.attr_name) 
    SQL> @$ORACLE_HOME/rdbms/admin/utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 651267974
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    |* 1 | FILTER | |
    | 2 | NESTED LOOPS | |
    | 3 | NESTED LOOPS | |
    | 4 | NESTED LOOPS | |
    |* 5 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    PLAN_TABLE_OUTPUT
    |* 6 | TABLE ACCESS BY INDEX ROWID| PARAMETERTABLE |
    |* 7 | INDEX UNIQUE SCAN | PRIMARY_KY_PARAMETERTABLE |
    | 8 | TABLE ACCESS BY INDEX ROWID | PARAMETERTABLE |
    |* 9 | INDEX RANGE SCAN | PRIMARY_KY_PARAMETERTABLE |
    | 10 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
    |* 11 | INDEX UNIQUE SCAN | SYS_C005695 |
    | 12 | NESTED LOOPS | |
    |* 13 | INDEX UNIQUE SCAN | PRIMARY_KY_PARAMETERTABLE |
    |* 14 | INDEX UNIQUE SCAN | PRIMARY_KEY_TRTABLE |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
    1 - filter( EXISTS (SELECT 0 FROM "TEMPLATERELATIONTABLE"
    "TEMPLATETAB2","PARAMETERTABLE" "PARAMTAB2" WHERE
    "PARAMTAB2"."ATTR_NAME"=:B1 AND "PARAMTAB2"."ID"=:B2 AND
    "PARAMTAB2"."ID"="TEMPLATETAB2"."TEMPLATE_ID" AND
    "TEMPLATETAB2"."ID"=:B3))
    5 - access("FDNTAB"."ID"=52787)
    6 - filter("PARAMTAB1"."ATTR_VALUE"<>'DEFAULT')
    7 - access("PARAMTAB1"."ID"="FDNTAB"."ID" AND
    PLAN_TABLE_OUTPUT
    "PARAMTAB1"."ATTR_NAME"='harqUsersMax')
    9 - access("PARAMTAB3"."ID"="FDNTAB"."ID")
    11 - access("PARAMTAB3"."ATTR_VALUE"="FDNTAB2"."FDN")
    13 - access("PARAMTAB2"."ID"=:B1 AND "PARAMTAB2"."ATTR_NAME"=:B2)
    14 - access("TEMPLATETAB2"."ID"=:B1 AND
    "PARAMTAB2"."ID"="TEMPLATETAB2"."TEMPLATE_ID")
    Note
    - rule based optimizer used (consider using cbo)
    43 rows selected.
    WITH INDEX HINT:
    select /*+INDEX(fdnmappingtable[PRIMARY_KY_FDNMAPPINGTABLE],parametertable[PRIMARY_KY_PARAMETERTABLE])*/ FdnTab2.fdn, paramTab3.attr_name from fdnmappingtable FdnTab, fdnmappingtable FdnTab2, parametertable paramTab1 ,parametertable paramTab3 where FdnTab.id=52787 and paramTab1.id= FdnTab.id and paramTab3.id = FdnTab.id and paramTab3.attr_value = FdnTab2.fdn and paramTab1.attr_name='harqUsersMax' and paramTab1.attr_value <> 'DEFAULT' and exists ( select ParamTab2.attr_name from parametertable ParamTab2, templaterelationtable TemplateTab2 where TemplateTab2.id=FdnTab.id and ParamTab2.id=TemplateTab2.template_id and ParamTab2.id=FdnTab2.id and ParamTab2.attr_name=paramTab1.attr_name);
    SQL> @$ORACLE_HOME/rdbms/admin/utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 2924316070
    | Id | Operation | Name | Rows | B
    ytes | Cost (%CPU)| Time |
    PLAN_TABLE_OUTPUT
    | 0 | SELECT STATEMENT | | 1 |
    916 | 6 (0)| 00:00:01 |
    |* 1 | FILTER | | |
    | | |
    | 2 | NESTED LOOPS | | 1 |
    916 | 4 (0)| 00:00:01 |
    | 3 | NESTED LOOPS | | 1 |
    401 | 3 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    | 4 | NESTED LOOPS | | 1 |
    207 | 2 (0)| 00:00:01 |
    |* 5 | TABLE ACCESS BY INDEX ROWID| PARAMETERTABLE | 1 |
    194 | 1 (0)| 00:00:01 |
    |* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_PARAMETERTABLE | 1 |
    | 1 (0)| 00:00:01 |
    |* 7 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE | 1 |
    PLAN_TABLE_OUTPUT
    13 | 1 (0)| 00:00:01 |
    | 8 | TABLE ACCESS BY INDEX ROWID | PARAMETERTABLE | 1 |
    194 | 1 (0)| 00:00:01 |
    |* 9 | INDEX RANGE SCAN | PRIMARY_KY_PARAMETERTABLE | 1 |
    | 1 (0)| 00:00:01 |
    | 10 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE | 1 |
    515 | 1 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 11 | INDEX UNIQUE SCAN | SYS_C005695 | 1 |
    | 1 (0)| 00:00:01 |
    | 12 | NESTED LOOPS | | 1 |
    91 | 2 (0)| 00:00:01 |
    |* 13 | INDEX UNIQUE SCAN | PRIMARY_KEY_TRTABLE | 1 |
    26 | 1 (0)| 00:00:01 |
    |* 14 | INDEX UNIQUE SCAN | PRIMARY_KY_PARAMETERTABLE | 1 |
    65 | 1 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
    1 - filter( EXISTS (SELECT /*+ */ 0 FROM "TEMPLATERELATIONTABLE" "TEMPLATETAB
    2","PARAMETERTABLE"
    PLAN_TABLE_OUTPUT
    "PARAMTAB2" WHERE "PARAMTAB2"."ATTR_NAME"=:B1 AND "PARAMTAB2"."ID"
    =:B2 AND
    "TEMPLATETAB2"."TEMPLATE_ID"=:B3 AND "TEMPLATETAB2"."ID"=:B4))
    5 - filter("PARAMTAB1"."ATTR_VALUE"<>'DEFAULT')
    6 - access("PARAMTAB1"."ID"=52787 AND "PARAMTAB1"."ATTR_NAME"='harqUsersMax')
    7 - access("FDNTAB"."ID"=52787)
    9 - access("PARAMTAB3"."ID"=52787)
    11 - access("PARAMTAB3"."ATTR_VALUE"="FDNTAB2"."FDN")
    13 - access("TEMPLATETAB2"."ID"=:B1 AND "TEMPLATETAB2"."TEMPLATE_ID"=:B2)
    14 - access("PARAMTAB2"."ID"=:B1 AND "PARAMTAB2"."ATTR_NAME"=:B2)
    PLAN_TABLE_OUTPUT
    Note
    - dynamic sampling used for this statement
    39 rows selected.

  • Poor query performance only with migrated 7.0 queries

    Dear Team,
    We are facing a serious query performance issue after migration of queries from 3.5 to 7.0.
    I executed a query in 3.5 with some variable values which takes fraction of seconds to display the output. But the same migrated query with same variable entries is taking very long time and giving time out error.
    We are not using any aggregates in the InfoProvider level.
    Both the queries are based on same cube but 3.5 query is taking less time and 7.0 is taking very long time if more selection is done.
    I checked for notes where I didn't find specific note for this particular scenario. I found notes only for general query performance improvement.
    I want to know the reason why only in 7.0 the same 3.5 query is taking a long time and giving time out error. And please suggest some notes or suggestions related to this scenario.
    Regards,
    Chan

    Hi,
    Queries in BI 7.0 are almost the same as queries in 3.x format.
    inorder to check if the problem is in the query runtime (database time) or JAVA runtime (probably rendering) you should try running it from RSRT once in JAVA web and once in ABAP web.
    if the problem is only with JAVA web, than u should take the URL and add &profiling=X at the end.
    after the query execution u can use statistics which will be shown at the top of the page.
    With my experience, the problem is in the rendering phase of the query. Things that could be done is to limit the number of rows shown at each page, that could be done by changing the 0ANALYSIS web template - it's one of the web template parameters.
    Tomer.

  • SAP BW 3.5 Query Cache - no data for queries

    Dear experts,
    we do have a problem with the SAP BW Query Cache (BW 3.5). Sometimes the
    problem arise that after the queries have been pre-calculated using web templates there are no figures available when running a web-report, or when doing a drilldown or filter navigation. A solution to solve that issue is to delete the cache for that query, however this solution is not reasonable or passable. The problem occurs non-reproducible for different queries.
    Is this a "normal" error of the SAP BW we have to live with, or are there any solutions for it? Any hints are greatly appreciated.
    Thanks in advance & kind regards,
    daniel

    HI Daniel
    Try to wirk without cache for those queries.
    Anyway, you should check how the cache option is configured for those queries .
    You can see that, in RSRV tx
    Hope this help

  • Create a VC Model for BEx queries with Cell Editor

    Hello All,
    I am trying to create a VC Model for BEx queries with Cell Editor.
    BW Development Team has created a BEX query with complex restrictions and calculations using Cell Editor feature of BI-BEX.
    The query output in BEx analyzer is correct where all values are being calculated at each Cell level and being displayed.
    But, while creating VC model, system is not displaying the Cells.Thus, no VC Model can be created.
    I have executed below steps:
    1. Created a VC Model for BEx Query - ZQRY_XYZ
    2. Create Iview -> Create a dataService -> Provide a Table from the Output
    In the Column field system is not showing any of the Cells (present in Cell Editor)
    Please help me to solve this issue.
    Thanks,
    Siva

    Hi
    If 'Cell Editor' is been used then that query must have the structure in it. You have to select that 'structure' object in your 'VC Table'.
    If you select that then you will get the required result in the output. This structure will be the structure where 'cell reference' is used in BI query, You have to select that structures name.
    Regards
    Sandeep

  • Tricky query with multiple hierarchial sub queries

    Here's a pussle that I cannot solve. Who can help me?
    Given table F (records form a binary tree with levels 0, 1, and
    2):
    Id IdParent
    F1 null
    F2 F1
    F3 F2
    F4 F2
    F5 F1
    F6 F5
    F7 F5
    and given table D (records form a similar binary tree with
    levels 0, 1, and 2):
    Id IdParent
    D1 null
    D2 D1
    D3 D2
    D4 D2
    D5 D1
    D6 D5
    D7 D5
    and given table P (cross referencing tables F and D):
    IdF IdD
    F2 D6
    F3 D2
    F5 D7
    and given table S (which holds the seed to the query):
    IdF
    F3
    and given table I (just any collection of records that reference
    table D which we want to select records from):
    Id IdD
    I1 D1
    I2 D2
    I3 D3
    I4 D4
    I5 D5
    I6 D6
    I7 D7
    I8 D1
    I9 D5
    all together being related like in figure 1:
    S.IdF =>> F.Id
    F.Id <- P.IdF
    P.IdD -> D.Id
    D.Id <<= I.IdD
    where =>> denotes 'is or is a descenden of'
    and -> denotes 'is'
    I want to build a query that lets me select all records from
    table I, which reference table D, such that the referenced
    records in table D are hierarchial descendents of any record
    that is referenced by records in table P, for which they
    reference records in table F, which are ancestors to records
    referenced by records in table S.
    If it wasn't for the hierarchial approach on both sides of the
    cross referencing table, matters would have been easy. Then the
    releational map would have been like in figure 2:
    S.IdF <- P.IdF
    P.IdD -> I.IdD
    and the query would have been:
    SELECT I.Id
    FROM I, P, S
    WHERE I.IdD = P.IdD
    AND P.IdF = S.IdF
    So in what I am looking for, you may say that the '='-signs in
    this select statement should denote 'is or is a descenden of'
    going towards the side of table P.
    Given the tables listed above and given the query I am seeking,
    I expect to retrieve the following result set:
    I.Id
    I2
    I3
    I4
    I6
    Tricky, eh? I belive the figures are the best angles to
    understand this problem.

    You do this with subqueries and hierarchical queries...
    First the hierarchal subquery on F...
    SQL> SELECT f.id
      2    FROM f
      3   CONNECT BY PRIOR f.idp = f.id
      4   START WITH f.id IN ( SELECT idf FROM s )
      5       ;
    ID
    F3
    F2
    F1
    Then join with the cross reference table...
    SQL> SELECT p.idd
      2    FROM p
      3       , (  SELECT f.id
      4              FROM f
      5             START WITH f.id IN ( SELECT idf FROM s )
      6             CONNECT BY PRIOR f.idp = f.id
      7         ) s
      8   WHERE s.id = p.idf
      9       ;
    ID
    D6
    D2
    Use this as a subquery in a hierarchial query for the
    descendents in D...
    SQL> SELECT d.id
      2    FROM d
      3   START WITH d.idd IN ( SELECT p.idd
      4                         FROM p
      5                            , ( SELECT f.id
      6                                  FROM f
      7                                 START WITH f.id IN ( SELECT
    idf FROM s )
      8                                 CONNECT BY PRIOR f.idp = f.id
      9                             ) s
    10                        WHERE s.id = p.idf
    11                      )
    12   CONNECT BY PRIOR d.id = d.idp
    13       ;
    ID
    D2
    D3
    D4
    D6
    Then use that as a subquery to return the I result set...
    SQL> SELECT i.id
      2    FROM i
      3   WHERE i.idd  IN  ( SELECT d.id
      4                        FROM d
      5                       START WITH d.id IN ( SELECT p.idd
      6                                             FROM p
      7                                                , ( SELECT
    f.id
      8                                                      FROM f
      9                                                     START
    WITH f.id IN ( SELECT idf FROM s )
    10                                                     CONNECT
    BY PRIOR f.idp = f.id
    11                                                 ) s
    12                                            WHERE s.id = p.idf
    13                                          )
    14                       CONNECT BY PRIOR d.id = d.idp
    15                    )
    16       ;
    ID
    I2
    I3
    I4
    I6Good Luck...

  • Query takes longer to run with indexes.

    Here is my situation. I had a query which I use to run in Production (oracle 9.2.0.5) and Reporting database (9.2.0.3). The time taken to run in both databases was almost the same until 2 months ago which was about 2 minutes. Now in production the query does not run at all where as in Reporting it continues to run in about 2 minutes. Some of the things I obsevred in P are 1) the optimizer_index_cost_adj parameter was changed to 20 from 100 in order to improve the performance of a paycalc program about 3 months ago. Even with this parameter being set to 20, the query use to run in 2 minutes until 2 months ago. in the last two months the GL table increased in size from 25 million rows to 27 million rows. With optimizer_index_cost_adj of 20 and Gl table of 25 million rows it runs fine, but with 27 million rows it does not run at all. If I change the value of optimizer_index_cost_adj to 100 then the query runs with 27 million rows in 2 minutes and I found that it uses full table scan. In Reporting database it always used full table sacn as found thru explain plan. CBO determines which scan is best and it uses that. So my question is that by making optimizer_index_cost_adj = 20, does oracle forces it to use index scan when the table size is 27 million rows? Isn't the index scan is not faster than full table scan? In what situation the full table scan is faster than index scan? If I drop all the indexes on the GL table then the query runs faster in production as it uses full table scan. What is the real benefit of changing optimizer_index_cost_adj values? Any input is most welcome.

    Isn't the index scan is not faster than full table scan? In what situation the full table scan is faster than index scan? No. It is not about which one is the "+fastest+" as that concept is flawed. How can an index be "faster" than a table for example? Does it have better tires and shinier paint job? ;-)
    It is about the amount of I/O that the database needs to perform in order to use that object's contents for resolving/executing that applicable SQL statement.
    If the CBO determines that it needs a 100 widgets worth of I/O to scan the index, and then another 100 widgets of I/O to scan the table, it may decide to not use the index at all, as a full table scan will cost only a 180 I/O widgets - 20 less than the combined scanning of index and table.
    Also, a full scan can make use of multi-block reads - and this, on most storage/file systems, is faster than single block reads.
    So no - a full table scan is NOT a Bad Thing (tm) and not an indicator of a problem. The thing that is of concern is the amount of I/O. The more I/O, the slower the operation. So obviously, we want to make sure that we design SQL that requires the minimal amount of I/O, design a database that support minimal I/O to find the required data (using clusters/partitions/IOTs/indexes/etc), and then check that the CBO also follows suit (which can be the complex bit).
    But before questioning the CBO, first question your code and design - and whether or not they provide the optimal (smallest) I/O footprint for the job at hand.

Maybe you are looking for

  • Workflow: User Decision Activity doesn't work

    friends, URGENT!!! I've created a User Decision Activity but it doesn't work. It sends a message to SBWP but there the user hit APROVE  OR REJECT, and instead it work, it simply show another screen with only a button labelad "Cancel and keep work ite

  • How to get my calendars iphone to snyc with my macbookpro?

    Trying to get my iphone calendar to download events calendared to my macbook pro's calendar. the iphone says it's synced with gmail, but my computeres calendar does not update, any ideas?

  • Twist Returns At Staples

    Lenovo might want to rethink your relationship with Staples.   The manger at the local Staples was a complete jerk with me when I returned my Twist.  He said that all touch screen laptops will only have 3 hours of battery during active use and that I

  • Goods supplier

    hi guys if i maintain GS as parner fun what extra adv i will get how it will effect at PO,MIGO,MIRO am not getting any diff while MIGO it showing sipmly in Partner TAb item details goods supplying vendor as some other vendor is there any other effect

  • I just downloaded the new Mac OS X v10.7 Lion, and now when I go on the Mac Store

    I just downloaded the new Mac OS X v10.7 Lion, and now when I go on the Mac Store to download a game (N.O.V.A 2) it goes straight to the Launch Pad, as it's supposed to, but the game it's self wont download, it just keeps saying "waiting" I never had