Stored Outlines & Restore Table Stats

Hi all,
I would like to know how restoring of table stats change execution plans when stored outlines are in place?
DB version is 10.2.0.4.
NAME                                 TYPE                             VALUE
optimizer_dynamic_sampling           integer                          0
optimizer_features_enable            string                           10.2.0.4
optimizer_index_caching              integer                          0
optimizer_index_cost_adj             integer                          65
optimizer_mode                       string                           FIRST_ROWS_10
optimizer_secure_view_merging        boolean                          TRUE
query_rewrite_enabled                string                           TRUE
star_transformation_enabled          string                           FALSE
Following actions were done last month:
1. dbms_stats.gather_table_stats(schema IMANAGE, Table DIT_TRUSTEE)
2. dbms_stats.lock_table_stats(schema IMANAGE, Table DIT_TRUSTEE)
3. Once the desired execution plan for Query 1 (e.g. sql_id=ah8nzqhyu7xh4) was in V$SQL and was used by query, I created a Stored Outline using DBMS_OUTLN.create_outline, and enabled outline by setting use_stored_outlines to the desired outline category.
4. Every thing remained fine for almost 30-35 days
Today, there was another query (e.g. sql_id=7anr84k12d5rt, using same DIT_TRUSTEE table) whose  query plan got changed. This query didn't have any stored outline in place and was performing without any problem earlier. So, I gathered stats for the same table (DIT_TRUSTEE) after unlocking its stats. It didn't help. So, I thought to restore old stats against which query used to perform better while also rebuilt some indexes. After the restore of table stats (DIT_TRUSTEE) to a date which was earlier than the date of creation of 1st stored outline, the execution plan of query 1 (e.g. sql_id=ah8nzqhyu7xh4) got changed. Can we know the reason why it got changed? I was under the impression that any change in stats doesn't impact the execution plan if stored outline is in place for a query. But it looked like this wasn't the case.
It would be good if someone can explain or share their experiences.
regards,
Anjum

Hi,
The query against SQL_ID=ah8nzqhyu7xh4 is:
SELECT imanage.DIT_TRUSTEE.CREATED_TIME, imanage.DIT_TRUSTEE.DIT_CLASS, imanage.DIT_TRUSTEE.DOES_PASSWORD_EXPIRE, imanage.DIT_TRUSTEE.DOMAIN, imanage.DIT_TRUSTEE.FORCE_PASSWORD_CHANGE, imanage.DIT_TRUSTEE.HOME_LIBRARY, imanage.DIT_TRUSTEE.IS_DELETED, imanage.DIT_TRUSTEE.IS_ENABLED, imanage.DIT_TRUSTEE.IS_LEAF_NODE, imanage.DIT_TRUSTEE.LABEL_F21011, imanage.DIT_TRUSTEE.LOGIN_LOCKOUT_TIME, imanage.DIT_TRUSTEE.MODIFIED_TIME, imanage.DIT_TRUSTEE.PARENT_TRUSTEE_RSID, imanage.DIT_TRUSTEE.PASSWORD_F21015, imanage.DIT_TRUSTEE.PASSWORD_FAIL_COUNT, imanage.DIT_TRUSTEE.PASSWORD_MODIFIED_TIME, imanage.DIT_TRUSTEE.RDN, imanage.DIT_TRUSTEE.REPLICATION_ID, imanage.DIT_TRUSTEE.SID, imanage.DIT_TRUSTEE.SYNCHRONIZE_ID, imanage.DIT_TRUSTEE.SYNCHRONIZED_TIME, imanage.DIT_TRUSTEE.TRUSTEE_TYPE, imanage.DIT_TRUSTEE.UID_F21024, imanage.DIT_TRUSTEE.WORKSPACE_LIBRARY, imanage.DIT_TRUSTEE.WORKSPACE_RSID, imanage.DIT_TRUSTEE.IS_WORKSPACE_LIBRARY_INHERITED, imanage.DIT_TRUSTEE.IS_HOME_LIBRARY_INHERITED, imanage.DIT_TRUSTEE.S_CCSSBL_LBRRY_LST_NHRT_F60326, imanage.DIT_TRUSTEE.NAME_FIRST, imanage.DIT_TRUSTEE.NAME_MIDDLE, imanage.DIT_TRUSTEE.NAME_LAST, imanage.DIT_TRUSTEE.NAME_FULL, imanage.DIT_TRUSTEE.NAME_SUFFIX, imanage.DIT_TRUSTEE.NAME_SALUTATION, imanage.DIT_TRUSTEE.GENDER, imanage.DIT_TRUSTEE.JOB_TITLE, imanage.DIT_TRUSTEE.ANNIVERSARY, imanage.DIT_TRUSTEE.BIRTHDATE, imanage.DIT_TRUSTEE.ASSISTANT_RSID, imanage.DIT_TRUSTEE.LOCALE_LANGUAGE, imanage.DIT_TRUSTEE.LOCALE_COUNTRY, imanage.DIT_TRUSTEE.LOCALE_TIMEZONE, imanage.DIT_TRUSTEE.EMAIL_1, imanage.DIT_TRUSTEE.EMAIL_2, imanage.DIT_TRUSTEE.EMAIL_3, imanage.DIT_TRUSTEE.EMAIL_FORMAT_1, imanage.DIT_TRUSTEE.EMAIL_FORMAT_2, imanage.DIT_TRUSTEE.EMAIL_FORMAT_3, imanage.DIT_TRUSTEE.IM_ID, imanage.DIT_TRUSTEE.PHONE_HOME, imanage.DIT_TRUSTEE.PHONE_BUSINESS, imanage.DIT_TRUSTEE.PHONE_MOBILE, imanage.DIT_TRUSTEE.PHONE_PAGER, imanage.DIT_TRUSTEE.PHONE_OTHER, imanage.DIT_TRUSTEE.FAX_HOME, imanage.DIT_TRUSTEE.FAX_BUSINESS, imanage.DIT_TRUSTEE.FAX_OTHER, imanage.DIT_TRUSTEE.MAILING_ADDRESS, imanage.DIT_TRUSTEE.BA_DEPARTMENT, imanage.DIT_TRUSTEE.BA_LOCATION, imanage.DIT_TRUSTEE.BA_COMPANY, imanage.DIT_TRUSTEE.BA_STREET_1, imanage.DIT_TRUSTEE.BA_STREET_2, imanage.DIT_TRUSTEE.BA_POBOX, imanage.DIT_TRUSTEE.BA_CITY, imanage.DIT_TRUSTEE.BA_STATE, imanage.DIT_TRUSTEE.BA_COUNTRY, imanage.DIT_TRUSTEE.BA_POSTAL_CODE, imanage.DIT_TRUSTEE.HA_STREET_1, imanage.DIT_TRUSTEE.HA_STREET_2, imanage.DIT_TRUSTEE.HA_POBOX, imanage.DIT_TRUSTEE.HA_CITY, imanage.DIT_TRUSTEE.HA_STATE, imanage.DIT_TRUSTEE.HA_COUNTRY, imanage.DIT_TRUSTEE.HA_POSTAL_CODE, imanage.DIT_TRUSTEE.WP_HOME, imanage.DIT_TRUSTEE.WP_BUSINESS, imanage.DIT_TRUSTEE.WP_OTHER, imanage.DIT_TRUSTEE.NE_DELIVERY_MODE_IMMEDIATE, imanage.DIT_TRUSTEE.NE_DELIVERY_MODE_SUMMARY, imanage.DIT_TRUSTEE.NE_USER_PREFERENCE, imanage.DIT_TRUSTEE.NE_USER_SUMMARY_TIME, imanage.DIT_TRUSTEE.NE_COPY_TO_ASSISTANT, imanage.DIT_TRUSTEE.IS_EXTERNAL, imanage.DIT_TRUSTEE.IS_IS_EXTERNAL_INHERITED, imanage.DIT_TRUSTEE.NOTES, imanage.DIT_TRUSTEE.LOCATION_RSID, imanage.DIT_TRUSTEE.IS_ALL_IP_VALID, imanage.DIT_TRUSTEE.LAST_LOGON_TIME, imanage.DIT_TRUSTEE.S_HM_PG_WRKSPC_NHR_F4294966291, imanage.DIT_TRUSTEE.S_PRFRNCS_FCLTY_NH_F4294966292, imanage.DIT_TRUSTEE.HOME_PAGE_WORKSPACE, imanage.DIT_TRUSTEE.PREFERENCES_FACILITY, imanage.DIT_TRUSTEE.P_NEW_ITEM_INDICATOR, imanage.DIT_TRUSTEE.P_PWD_QUESTION, imanage.DIT_TRUSTEE.P_PWD_ANSWER, imanage.DIT_TRUSTEE.X_ECF_USER, imanage.DIT_TRUSTEE.X_DEPARTMENTS, imanage.DIT_TRUSTEE.X_TP_CLASSIFICATION, imanage.DIT_TRUSTEE.X_IMR_ENABLED_TIME, imanage.DIT_TRUSTEE.X_CAN_MANAGE_COI, imanage.DIT_TRUSTEE.X_CAN_ADD_THIRD_PARTY, imanage.DIT_TRUSTEE.X_IS_SECURITY_ADMINISTRATOR, imanage.DIT_TRUSTEE.X_IS_A_AND_S_DIRECT_LOAD, imanage.DIT_TRUSTEE.X_IS_ECF_DIRECT_LOAD, imanage.DIT_TRUSTEE.X_IS_NATIVE_REPOSITORY, imanage.DIT_TRUSTEE.X_CLIENT_CATEGORY, imanage.DIT_TRUSTEE.X_IS_ECF2_USER, imanage.DIT_TRUSTEE.X_IS_ECF2_ADMIN, imanage.DIT_TRUSTEE.X_CWS_UNIT, imanage.DIT_TRUSTEE.X_XCHANGING_ID, imanage.DIT_TRUSTEE.X_IS_DOCUMENT_FILE_VIEWER, imanage.DIT_TRUSTEE.X_IS_CWS_USER
FROM imanage.DIT_TRUSTEE
WHERE ((imanage.DIT_TRUSTEE.WORKSPACE_RSID = :"SYS_B_0") AND (UPPER(imanage.DIT_TRUSTEE.RDN) = :1)) ORDER BY imanage.DIT_TRUSTEE.NAME_FIRST ASC, imanage.DIT_TRUSTEE.NAME_LAST ASC, imanage.DIT_TRUSTEE.UID_F21024 ASC, imanage.DIT_TRUSTEE.RDN ASC
which shows the bind vars in place.
while definition of index IX_DIT_TRUSTEE_6 is:
CREATE INDEX "IMANAGE"."IX_DIT_TRUSTEE_6" ON "IMANAGE"."DIT_TRUSTEE" ("WORKSPACE_RSID", "DIT_CLASS", "SID") TABLESPACE "REPOS_INDX" PCTFREE 10INITRANS 2 MAXTRANS 255 STORAGE ( INITIAL 512K BUFFER_POOL DEFAULT) LOGGING LOCAL
Now, I below details explaining the index it started using despite outline in place:
SQL> select sql_id, HASH_VALUE, CHILD_NUMBER, users_executing from v$sql where PLAN_HASH_VALUE=2563299851;
SQL_ID        HASH_VALUE CHILD_NUMBER USERS_EXECUTING
ah8nzqhyu7xh4 1034155524            1               0
SQL> SELECT hash_value, child_number, sql_text FROM v$sql WHERE sql_id='ah8nzqhyu7xh4';
HASH_VALUE CHILD_NUMBER
SQL_TEXT
1034155524            1
SELECT imanage.DIT_TRUSTEE.CREATED_TIME, imanage.DIT_TRUSTEE.DIT_CLASS, imanage.DIT_TRUSTEE.DOES_PASSWORD_EXPIRE, imanage.DIT_TRUSTEE.DOMAIN, imanage.DIT_TRUSTEE.FORCE_PASSWORD_CHANGE, imanage.DIT_TRU
STEE.HOME_LIBRARY, imanage.DIT_TRUSTEE.IS_DELETED, imanage.DIT_TRUSTEE.IS_ENABLED, imanage.DIT_TRUSTEE.IS_LEAF_NODE, imanage.DIT_TRUSTEE.LABEL_F21011, imanage.DIT_TRUSTEE.LOGIN_LOCKOUT_TIME, imanage.D
IT_TRUSTEE.MODIFIED_TIME, imanage.DIT_TRUSTEE.PARENT_TRUSTEE_RSID, imanage.DIT_TRUSTEE.PASSWORD_F21015, imanage.DIT_TRUSTEE.PASSWORD_FAIL_COUNT, imanage.DIT_TRUSTEE.PASSWORD_MODIFIED_TIME, imanage.DIT
_TRUSTEE.RDN, imanage.DIT_TRUSTEE.REPLICATION_ID, imanage.DIT_TRUSTEE.SID, imanage.DIT_TRUSTEE.SYNCHRONIZE_ID, imanage.DIT_TRUSTEE.SYNCHRONIZED_TIME, imanage.DIT_TRUSTEE.TRUSTEE_TYPE, imanage.DIT_TRUS
TEE.UID_F21024, imanage.DIT_TRUSTEE.WORKSPACE_LIBRARY, imanage.DIT_TRUSTEE.WORKSPACE_RSID, imanage.DIT_TRUSTEE.IS_WORKSPACE_LIBRARY_INHERITED, imanage.DIT_TRUSTEE.IS_HOME_LIBRARY_INHERITED, imanage.DI
SQL> SELECT * FROM table(DBMS_XPLAN.DISPLAY_CURSOR('ah8nzqhyu7xh4',1));
PLAN_TABLE_OUTPUT
SQL_ID  ah8nzqhyu7xh4, child number 1
SELECT imanage.DIT_TRUSTEE.CREATED_TIME, imanage.DIT_TRUSTEE.DIT_CLASS,
imanage.DIT_TRUSTEE.DOES_PASSWORD_EXPIRE, imanage.DIT_TRUSTEE.DOMAIN,
imanage.DIT_TRUSTEE.FORCE_PASSWORD_CHANGE, imanage.DIT_TRUSTEE.HOME_LIBRARY,
imanage.DIT_TRUSTEE.IS_DELETED, imanage.DIT_TRUSTEE.IS_ENABLED,
imanage.DIT_TRUSTEE.IS_LEAF_NODE, imanage.DIT_TRUSTEE.LABEL_F21011,
imanage.DIT_TRUSTEE.LOGIN_LOCKOUT_TIME, imanage.DIT_TRUSTEE.MODIFIED_TIME,
imanage.DIT_TRUSTEE.PARENT_TRUSTEE_RSID, imanage.DIT_TRUSTEE.PASSWORD_F21015,
imanage.DIT_TRUSTEE.PASSWORD_FAIL_COUNT, imanage.DIT_TRUSTEE.PASSWORD_MODIFIED_TIME,
imanage.DIT_TRUSTEE.RDN, imanage.DIT_TRUSTEE.REPLICATION_ID, imanage.DIT_TRUSTEE.SID,
imanage.DIT_TRUSTEE.SYNCHRONIZE_ID, imanage.DIT_TRUSTEE.SYNCHRONIZED_TIME,
imanage.DIT_TRUSTEE.TRUSTEE_TYPE, imanage.DIT_TRUSTEE.UID_F21024,
imanage.DIT_TRUSTEE.WORKSPACE_LIBRARY, imanage.DIT_TRUSTEE.WORKSPACE_RSID,
imanage.DIT_TRUSTEE.IS_WORKSPACE_LIBRARY_INHERITED,
imanage.DIT_TRUSTEE.IS_HOME_LIBRARY_INHERITED, imanage.DI
Plan hash value: 2563299851
| Id  | Operation                    | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT             |                      |       |       |     4 (100)|          |
|   1 |  SORT ORDER BY               |                      |     1 |   248 |     4  (25)| 00:00:01 |
|*  2 |   TABLE ACCESS BY INDEX ROWID| DIT_TRUSTEE          |     1 |   248 |     3   (0)| 00:00:01 |
|*  3 |    INDEX RANGE SCAN          | DIT_TRUSTEE_TST1_IDX |     1 |       |     2   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - filter("DIT_TRUSTEE"."WORKSPACE_RSID"=:SYS_B_0)
   3 - access("DIT_TRUSTEE"."SYS_NC00096$"=:1)
Note
   - outline "SYS_OUTLINE_13100417531513606" used for this statement
38 rows selected.
Definition of index DIT_TRUSTEE_TST1_IDX is:
CREATE INDEX "IMANAGE"."DIT_TRUSTEE_TST1_IDX" ON "IMANAGE"."DIT_TRUSTEE" (UPPER("RDN")) TABLESPACE "REPOS_INDX" PCTFREE 10 INITRANS 2 MAXTRANS 255STORAGE ( INITIAL 512K BUFFER_POOL DEFAULT) LOGGING LOCAL
I didnt want the query to use index DIT_TRUSTEE_TST1_IDX as it performs bad for the customer as compare to index IX_DIT_TRUSTEE_6
The question arises here is that can we force an index to be used as part of stored outline because when we created outline, it was using index IX_DIT_TRUSTEE_6.

Similar Messages

  • Use Stored Outlines to replace ANALYZE  with "do nothing" ?

    Has anyone used Stored Outlines to replace statements like "ANALYZE TABLE abc COMPUTE STATISTICS" ?
    Say you have an application that issues a number of 'ANALYZE TABLE' statements at different times during a batch run and you want some of the ANALYZE calls to succeed (eg for tables 'stu' and 'xyz') but others to "do nothing" (eg for table 'abc').
    Could you replace "ANALYZE TABLE abc COMPUTE STATISTICS" with a (for example) "select 'x' from dual" call ?

    Hemant K Chitale wrote:
    Has anyone used Stored Outlines to replace statements like "ANALYZE TABLE abc COMPUTE STATISTICS" ?
    Say you have an application that issues a number of 'ANALYZE TABLE' statements at different times during a batch run and you want some of the ANALYZE calls to succeed (eg for tables 'stu' and 'xyz') but others to "do nothing" (eg for table 'abc').
    Could you replace "ANALYZE TABLE abc COMPUTE STATISTICS" with a (for example) "select 'x' from dual" call ?
    If i understood it right, you seem to mean query rewrite.
    As you know already, stored outline is a series of hints to guide optimizer to emulate previous plan.
    It cannot be used to replace query text itself.
    Advanced query rewrite(10g) seems to be promising, but it can only be used for select statement.
    Dion Cho
    PS) Rewriting query is very powerful, but very dangerous both for performance and security.
    That is maybe the reason why Oracle does not provide those kinds of functionality.

  • Stored outlines & plan stability

    I am trying to use stored outlines, for plan stability (Oracle 8i).
    Oracle documents says that; the query from my
    application must literally match to the one
    in stored outline (OL$ table). Does that mean
    that the parameter value(s) also should
    match ??
    Example: The following query was stored
    in OL$ table, thru stored outlines procedure.
    select cust_name, sum(revenue)
    from accounts
    where country_code = '225'
    and account_type = 'C'
    group by cust_name;
    Now my question: Is it necessary that my application should throw exact same query,
    including parameter values (i.e.country_code)
    to take advantage of the store outline ?
    If I pass country_code = '436', does it make use of the stored outline or not ?
    Any input is highly appreciated, since this option is very useful in my application
    context.
    thanks and regards
    subbu

    The stored outline need not take the same parameter values .we can give different parameter values.In your case if country_code = '436', it makes use of stored outline.

  • Do stored outlines work in Oracle 10.2.0.3?

    I am using 10.2.0.3 on HP UNIX 11i. I set cursor_sharing=force.
    I created a stored outline using:
    alter session set create_stored_outlines='CUSTOM';
    my sql_statement;
    When I run the sql statement and verify in v$sql whether outline was used by looking at outline_category and yes outline is used.
    But then I run dbms_stat on an underlying table and run my sql again, my plan has changed which means outline was not used. This is really baffling, if outline was used,
    Plan should be same as what was produced when creating outline. Something is
    Definitely wrong.

    After spending whole day, I narrowed down the proble. Stored outlines in 10.2.0.3
    do not work anymore whith cursor_sharing=force. They, however, they work with
    cusror_sharing=similar and cirsor_sahring=exact.

  • Oracle not using the stored outline

    SQL> create table emp as select * from sys.emp;
    Table created.
    SQL> alter session set create_stored_outlines = TRUE;
    Session altered.
    SQL> create outline emp_dept for category scott_outlines on select empno from emp where ename = 'SCOTT';
    Outline created.
    SQL> set autot on exp
    SQL> select empno from emp where ename = 'SCOTT';
    EMPNO
    7788
    Execution Plan
    Plan hash value: 3956160932
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 20 | 2 (0)| 00:00:01 |
    |* 1 | TABLE ACCESS FULL| EMP | 1 | 20 | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter("ENAME"='SCOTT')
    Note
    - dynamic sampling used for this statement (level=2)
    SQL> create unique index i on emp(ename);
    Index created.
    SQL> select empno from emp where ename = 'SCOTT';
    EMPNO
    7788
    Execution Plan
    Plan hash value: 3262377121
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
    |
    | 0 | SELECT STATEMENT | | 1 | 20 | 1 (0)| 00:00:
    01 |
    | 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 20 | 1 (0)| 00:00:
    01 |
    |* 2 | INDEX UNIQUE SCAN | I | 1 | | 0 (0)| 00:00:
    01 |
    Predicate Information (identified by operation id):
    2 - access("ENAME"='SCOTT')
    SQL> alter session set use_stored_outlines = SCOTT_OUTLIN
    2 ;
    Session altered.
    SQL> alter session set use_stored_outlines = SCOTT_OUTLINS
    2 ;
    Session altered.
    SQL> select empno from emp where ename = 'SCOTT';
    EMPNO
    7788
    Execution Plan
    Plan hash value: 3262377121
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
    |
    | 0 | SELECT STATEMENT | | 1 | 20 | 1 (0)| 00:00:
    01 |
    | 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 20 | 1 (0)| 00:00:
    01 |
    |* 2 | INDEX UNIQUE SCAN | I | 1 | | 0 (0)| 00:00:
    01 |
    Predicate Information (identified by operation id):
    2 - access("ENAME"='SCOTT')
    Note
    - outline "SYS_OUTLINE_11050409142489113" used for this statement
    SQL> SELECT name, category, used FROM user_outlines;
    NAME CATEGORY USED
    EMP_DEPT SCOTT_OUTLINES UNUSED
    SYS_OUTLINE_11050408594412502 DEFAULT USED
    SYS_OUTLINE_11050408591781301 DEFAULT UNUSED
    SYS_OUTLINE_11050408594415603 DEFAULT UNUSED
    SYS_OUTLINE_11050408595648404 DEFAULT UNUSED
    SYS_OUTLINE_11050409003554705 DEFAULT UNUSED
    SYS_OUTLINE_11050409030340606 DEFAULT UNUSED
    7 rows selected.
    Execution Plan
    Plan hash value: 1195863419
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Ti
    me |
    | 0 | SELECT STATEMENT | | 1 | 81 | 2 (0)| 00
    :00:01 |
    | 1 | NESTED LOOPS | | | | |
    |
    | 2 | NESTED LOOPS | | 1 | 81 | 2 (0)| 00
    :00:01 |
    | 3 | TABLE ACCESS FULL | OL$ | 1 | 64 | 2 (0)| 00
    :00:01 |
    |* 4 | INDEX UNIQUE SCAN | I_USER1 | 1 | | 0 (0)| 00
    :00:01 |
    |* 5 | TABLE ACCESS BY INDEX ROWID| USER$ | 1 | 17 | 0 (0)| 00
    :00:01 |
    Predicate Information (identified by operation id):
    4 - access("CREATOR"="U"."NAME")
    5 - filter("U"."USER#"=USERENV('SCHEMAID'))
    Note
    - outline "SYS_OUTLINE_11050409030340606" used for this statement
    SQL>
    Note : I have dropped all default outlines in dba_outlines but they are being created automatically.(Why)
    Please give me good article to understand more on stored outlines.

    Please post your 4 digits Oracle version.
    It looks like that Oracle has only 1 stored outline for the SQL statement and that the second execution plan with the index has replaced the first outline (execution plan with full table scan).
    Here is a good article on stored outlines http://www.oracle-base.com/articles/misc/Outlines.php (except that the used Oracle version is also missing).
    Here is a short demo based on your demo that I have modified (note that I disabled stored outlines just after creating the first one):
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> drop table emp purge;
    Table dropped.
    SQL> drop outline emp_dept;
    Outline dropped.
    SQL> whenever sqlerror exit failure;
    SQL> --
    SQL> create table emp as
      2  select object_name ename, object_id empno
      3  from all_objects
      4  where object_id < 5000;
    Table created.
    SQL> --
    SQL> alter session set create_stored_outlines = TRUE;
    Session altered.
    SQL> create outline emp_dept for category scott_outlines on
    select empno from emp where ename = 'SCOTT';
    Outline created.
    SQL> set autot on exp
    SQL> select empno from emp where ename = 'SCOTT';
    no rows selected
    Execution Plan
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |    30 |     5   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |     1 |    30 |     5   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("ENAME"='SCOTT')
    Note
       - dynamic sampling used for this statement
    SQL> -- disable stored outline creation
    SQL> alter session set create_stored_outlines = FALSE;
    Session altered.
    SQL> create index i on emp(ename);
    Index created.
    SQL> select empno from emp where ename = 'SCOTT';
    no rows selected
    Execution Plan
    Plan hash value: 4079916893
    | Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |      |     1 |    30 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP  |     1 |    30 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | I    |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("ENAME"='SCOTT')
    Note
       - dynamic sampling used for this statement
    SQL> -- use stored outlines
    SQL> alter session set use_stored_outlines = SCOTT_OUTLINES;
    Session altered.
    SQL> select empno from emp where ename = 'SCOTT';
    no rows selected
    Execution Plan
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |    10 |   300 |     5   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |    10 |   300 |     5   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("ENAME"='SCOTT')
    Note
       - outline "EMP_DEPT" used for this statement
    SQL> -- do not use stored outlines
    SQL> alter session set use_stored_outlines=false;
    Session altered.
    SQL> select empno from emp where ename = 'SCOTT';
    no rows selected
    Execution Plan
    Plan hash value: 4079916893
    | Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |      |     1 |    30 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP  |     1 |    30 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | I    |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("ENAME"='SCOTT')
    Note
       - dynamic sampling used for this statementEdited by: P. Forstmann on 4 mai 2011 13:34

  • I want to know when we issue truncate table statement in oracle .

    i want to know when we issue truncate table statement in oracle .No log will be write in redo log .But we can recover data using flashback or scn.I want to know where is the actually truncate table statement log is stored in oracle database.Please explain me in detail step by step .

    Hi,
    I have truncated table after that i have restored that data.See below the example.I want to know from where it's restored.
    From which log file it's restored.
    create table mytab (n number, x varchar2(90), d date);
    alter table mytab enable row movement;
    Table altered.
    SQL> insert into mytab values (1,'Monsters of Folk',sysdate);
    1 row created.
    SQL> insert into mytab values (2,'The Frames',sysdate-1/24);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select CURRENT_SCN from v$database;
    CURRENT_SCN
    972383
    SQL> select * from mytab;
    N
    X
    D
    1
    Monsters of Folk
    30-DEC-12
    2
    The Frames
    30-DEC-12
    N
    X
    D
    SQL> set lines 10000
    SQL> /
    N X D
    1 Monsters of Folk 30-DEC-12
    2 The Frames 30-DEC-12
    SQL> select to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
    TO_CHAR(SYSDATE,'
    20121230 09:29:24
    SQL> set timing on
    SQL> truncate table mytab;
    Table truncated.
    Elapsed: 00:00:15.75
    SQL> select * from mytab as of timestamp TO_TIMESTAMP('20121230 09:29:24','yyyymmdd hh24:mi:ss');
    N X D
    1 Monsters of Folk 30-DEC-12
    2 The Frames 30-DEC-12
    Elapsed: 00:00:00.28
    SQL> insert into mytab select * from mytab as of timestamp TO_TIMESTAMP('20121230 09:29:24','yyyymmdd hh24:mi:ss');
    2 rows created.
    Elapsed: 00:00:00.01
    SQL>

  • Use of Stored Outlines

    I would like to know if the following workaround is possible thru' stored outlines...
    Can I create a stored outline for the following statement?
    SELECT TRIM(EMPNAME) FROM EMP WHERE EMPID=:B1 FOR UPDATE OF EMPNAME;
    Can I create a stored outline for the following statement?
    SELECT TRIM(EMPNAME) FROM EMP WHERE EMPID=:B1 FOR UPDATE;
    If the outlines could be created for both of the above sql statements, then I want to replace the outline for 1st sql with the outline of the 2nd sql...
    Let me know, if someone could help me on that as soon as possible...
    Thanks
    Siva

    ...and how exactly are the two SQLs different?There is a pretty big difference in terms of locking. When a 'select .... for update' statement doesn't have a 'of columnname' clause, the rows in ALL the select statement tables are locked. If the 'of columnname' clause is appended to the 'select .... for update' statement, only the rows in the table that have that column are locked. E.g.
    Session 1 SQL> select d.dname, e.empno from scott.dept d, scott.emp e where e.deptno = d.deptno for update;
    DNAME               EMPNO
    RESEARCH             7369
    SALES                7499
    SALES                7521
    RESEARCH             7566
    SALES                7654
    SALES                7698
    ACCOUNTING           7782
    RESEARCH             7788
    ACCOUNTING           7839
    SALES                7844
    RESEARCH             7876
    SALES                7900
    RESEARCH             7902
    ACCOUNTING           7934
    Session 2 SQL> update scott.dept set dname = 'Research' where dname = 'RESEARCH' ; .................Session 2 locks since session 1 holds exclusive locks on rows from emp and dept.
    Session 1 SQL> commit;
    Commit complete........going back to the locked session 2.....
    Session 2 SQL> update scott.dept set dname = 'Research' where dname = 'RESEARCH' ;
    1 row updated.
    Session 2 SQL> rollback;
    Rollback complete.Now lets try the select for update clause with the 'of columname' clause.
    Session 1 SQL> select d.dname, e.empno from scott.dept d, scott.emp e where e.deptno = d.deptno for update of empno;
    DNAME               EMPNO
    RESEARCH             7369
    SALES                7499
    SALES                7521
    RESEARCH             7566
    SALES                7654
    SALES                7698
    ACCOUNTING           7782
    RESEARCH             7788
    ACCOUNTING           7839
    SALES                7844
    RESEARCH             7876
    SALES                7900
    RESEARCH             7902
    ACCOUNTING           7934
    Session 2 SQL> update scott.dept set dname = 'Research' where dname = 'RESEARCH';
    1 row updated.As you can see, Session 2 does not lock.
    -Raj

  • Stored Outlines in SAP

    Hi,
    is anyone using stored outlines within SAP?
    Would you pleas share your experience with it's implementation.
    Thanks
    Volker

    Volker Borowski wrote:>
    > >
    YukonKid wrote:
    > > If you go for outlines you would need to
    > >
    > > a) capture the query exactly as it is executed by the application, hints and all
    > > yk
    > http://forums.sdn.sap.com/post!reply.jspa?messageID=8458029
    > Hi YK,
    >
    > this would be a major "gotcha".
    > My statement has bind variables and I am not able to force the plan
    > to the correct one by invalidating an index.
    > I either need a hint (which will not be in the generated code) or
    > change the sequence of the tables in the from clause.
    >
    > So in both ways the stored outline would refer to a statement,
    > that is literally diffrent.
    >
    > So if I got you correctly, I will not be able to like the plan of a statement to a diffrent one?
    no - it works the other way round:
    Statement A -> worse plan
    you would make it to use the more efficient plan (i.e. using session parameters and such)
    capture that plan and use it on Statement A.
    >
    >
    > The change I'd have to do would be
    >
    > :
    > FROM
    >   table1  T_00,
    >   table2  T_01,
    >   table3  T_02,
    >   table4  T_03,
    >   table5  T_04,
    >   table6  T_05,
    >   table7  T_06,
    >   table8  T_07,
    > WHERE
    > :
    >
    > to
    >
    > :
    > FROM
    >   table2  T_01,
    >   table3  T_02,
    >   table1  T_00,
    >   table4  T_03,
    >   table5  T_04,
    >   table6  T_05,
    >   table7  T_06,
    >   table8  T_07,
    > WHERE
    > :
    >
    > Now as for the SQL Syntax, this make absolutely no diffrence.
    > But the plan changes to effectively 50% less consistent gets (~12000 -> ~6500)
    > and the total optimizer costs for both plans are identical.
    >
    > So I would like to link the plan for statement 2 to the literal statement 1.
    If you have control over the statement check out the ORDERED hint and forget stored outlines
    SELECT /*+ ORDERED */ ....FROM ....WHERE
    tables get joined in the order of the from clause.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements006.htm#SQLRF50601
    But same applies: Don't try to be more clever than the CBO (99% of the time he is smarter than you)....
    >
    > Volker

  • Are the messages stored in any table

    Hi,
    while Changing a material in a Std Tcode i get the error Message  "Error in creation of the BoM". So, i was looking jf there is any way i can find the message class of this message, if it is stored in any table.
    Any suggestions please ?
    Thanks!

    Hello,
    Lemme rephrase my statement.
    Double click on the error message which is displayed, it will take you to some documentation screen where you can get the details.
    BR,
    Suhas

  • Display HTML stored in a table

    Hello,
    I want to display HTML Code which is stored in a table.
    Now I have a display as text item and there the HTML is not rendered properly...
    So what must i do to show the HTML Code properly?
    What kind of item should I use?
    Thank you,
    Tim

    Thank you Carsten,
    I had the wrong Item.
    I used "display as text (saves state)"....
    Regards,
    Tim

  • What is the best way to execute immediate particular sql stored in a table

    I have a string variable containing row_ids eg "12,24,35,23"
    and a table
    row_id, sql
    1 , "insert into some_table values(23,'Happy');"
    6 , "insert into some_other_table values(24,'Sad');"
    12 , "insert into some_table values(23,'Crazzzy');"
    15 , "insert into some_other_table values(23,'Old');"
    23 , "insert into another_table values(23,'Left');"
    24 , "insert into stuff_table values(23,'Gold');"
    30 , "insert into old_table values(23,'Even');"
    35 , "insert into archive_table values(23,"True");"
    And I need to write a plsql function that takes the list of row_ids as an argument and executes the sql statements stored in the table that matches.
    I am trying a combination of cursor and execute immediate statements to do it at the moment but suspect I am being very inefficient. So any suggestions or examples of similar code anyone knows about would be hugely appreciated.
    Cheers
    Reuben

    Not sure why anyone would be doing such a thing as storing their SQL in a table and wanting to dynamically execute it (generally this is bad practice), but if you must...
    SQL> select * from testdata;
        SQL_ID SQL_TEXT
             1 insert into some_table values(23,'Happy');
             6 insert into some_other_table values(24,'Sad');
            12 insert into some_table values(23,'Crazzzy');
            15 insert into some_other_table values(23,'Old');
            23 insert into another_table values(23,'Left');
            24 insert into stuff_table values(23,'Gold');
            30 insert into old_table values(23,'Even');
            35 insert into archive_table values(23,'True');
    8 rows selected.
    SQL> set serverout on
    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2    v_ids VARCHAR2(4000) := '12,24,35,23';
      3    CURSOR cur_fetch IS
      4      SELECT sql_text
      5      FROM   testdata
      6      WHERE  sql_id IN (SELECT TO_NUMBER(REGEXP_SUBSTR (v_ids, '[^,]+', 1, rownum))
      7                        FROM   DUAL
      8                        CONNECT BY ROWNUM <= length(regexp_replace(v_ids,'[^,]*'))+1);
      9  BEGIN
    10    FOR s IN cur_fetch
    11    LOOP
    12      DBMS_OUTPUT.PUT_LINE(s.sql_text); -- For demo purposes show the sql text
    13      -- EXECUTE IMMEDIATE s.sql_text; -- In reality, uncomment this to execute the sql text
    14    END LOOP;
    15* END;
    16  /
    insert into some_table values(23,'Crazzzy');
    insert into another_table values(23,'Left');
    insert into stuff_table values(23,'Gold');
    insert into archive_table values(23,'True');
    PL/SQL procedure successfully completed.
    SQL>

  • Report results need to be stored in a table

    Hello,
    I need to store the result of a program to be stored in a table so that i can load the cude.Can anyone help me with this.
    Thanks,
    Vinay

    I have a company table and a address detail table.
    SQL> desc company;
    Name Null? Type
    COMPANY_ID NOT NULL NUMBER(10)
    COMPANY_NAME VARCHAR2(50)
    COMPANY_DESCRIPTION VARCHAR2(1000)
    SQL> desc address_detail;
    Name Null? Type
    ADDRESS_ID NOT NULL NUMBER(10)
    COMPANY_ID NOT NULL NUMBER(10)
    ADDRESS_TYPE_ID NOT NULL NUMBER(10)
    ADDRESS_LINE1 VARCHAR2(100)
    ADDRESS_LINE3 VARCHAR2(100)
    ADDRESS_LINE2 VARCHAR2(100)
    CITY VARCHAR2(50)
    STATE VARCHAR2(50)
    ZIPCODE VARCHAR2(20)
    COUNTRY VARCHAR2(50)
    PHONE VARCHAR2(20)
    For a given company it can have multiple addresses. Address_type_id indicates if it is a ship_to, bill_to, headquarters etc.
    So for a given company I want to display all of its addresses as a single row.
    Thanks.

  • Why we use Tables statement in case of using SELECT-OPTIONS:

    hi all,
    Why we use Tables statement in case of using the following coding in an ABAP program ...
    tables: vbak.
    SELECT-OPTIONS: s1 for vbak-vbeln.
    here if we dont provide the tables statement why it does not work ????
    pls answwer ....???

    Hi
    This statement is not allowed in classes and declares a data object table_wa as a table work area whose data type is adopted from the identically named structured data type table_wa from the ABAP Dictionary. table_wa must be defined as a flat structure in the ABAP Dictionary. You can specify database tables or Views for table_wa.
    Work table areas declared with TABLES are interface work areas and should only be declared in the global declaration section of a program for the following purpose:
    reward if usefull
    The statement TABLES is required for exchanging data between screen fields that were defined in a program screen when transferring from the ABAP Dictionary and the ABAP program. For the screen event PBO, the content of the table work area is transferred to identically named screen fields; for PAI, the system adopts the data from identically named screen fields.
    In executable programs, flat table work areas can be used for adopting data that were provided for the event GET table_wa from a linked logical database. TABLES is synonymous with the statement NODES for this purpose.
    Work table areas declared with TABLES behave like the data declared with the addition COMMON PART, meaning the data are used by the programs of a program group.
    Table work areas declared with TABLES can be declared in subroutines and
    function modules. However, this is not recommended. A table work area declared in a procedure is not local but belongs to the context of a framework program. The table work area can be viewed starting from the declaration in the framework program and lives as long as the framework program. In contrast to normal program-global data, the content of the table work areas declared in subroutines and function modules is stored temporarily when these subroutines and function modules are called. Value assignments that were made during runtime of the procedure are preserved until the procedure is completed. When exiting the procedure, the table work areas are filled with the contents that they contained when the procedure was called. Table work areas declared in procedures behave like global data to which the statement LOCAL is applied in the procedure.
    The form TABLES * is obsolete.

  • ALDSP 3.0 -- schema owner for stored procedure or SQL Statement

    Using ALDSP, I have a need to create a physical service based on a stored procedure or a SQL statement. I am wondering what will happen when I move to another deployment environment where the schema owner changes. In our QA and Prod environments, we have a different schema owner for all tables in the application (the DBAs believe this prevents unwanted updates to a prod environment). DSP elegantly supports this for normal table- and view-based physical services by mapping schemas through the DSP console after deployment. Will I get the same type of mapping capability for stored procedures and SQL statements? I noticed that I can add a SQL-based function to a physical service...is there a way to pass in the physical table name from that data service to the procedure or SQL statement?
    Thanks,
    Jeff

    Schema name substitution should work for stored procedures just like it does for tables. If it doesn't - report a bug.
    You don't get any help for sql-statement based data services - dsp doesn't parse the sql provided. One thing you could do is use the default schema (following the user of your connection pool), and not specify the schema in your sql-statement.

  • Performance Tuning Issues: UNION and Stored Outlines

    Hi,
    I have two questions,
    Firstly I have read this:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/sql_1016.htm#i35699
    What I can understand is using UNION ALL is better than UNION.
    The ALL in UNION ALL is logically valid because of this exclusivity. It allows the plan to be carried out without an expensive sort to rule out duplicate rows for the two halves of the query.
    Can someone explain me the following sentences.
    Secondly my Oracle Database 10g is on FIRST_ROWS_1, how can stored outlines help in reducing I/O cost and response time in general?Please explain.
    Thank you,
    Adith

    Union ALL and Union
    SQL> select 1, 2 from dual
    union
    select 1, 2 from dual;
    | Id | Operation | Name | Rows | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 2 | 6 (67)| 00:00:01 |
    | 1 | SORT UNIQUE | | 2 | 6 (67)| 00:00:01 |
    | 2 | UNION-ALL | | | | |
    | 3 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
    | 4 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
    11 rows selected.
    SQL>select 1, 2 from dual
    union all
    select 1, 2 from dual;
    | Id | Operation | Name | Rows | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 2 | 4 (50)| 00:00:01 |
    | 1 | UNION-ALL | | | | |
    | 2 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
    | 3 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
    10 rows selected.
    Adith

Maybe you are looking for

  • Apple Zone

    I am trying to add a new Ricoh 4000 PostScript printer to my ethernet network. In the process, it asks for an Apple Zone. It is grayed out. I can download the PS fonts into the printers memory, but that's as far as I get so far as loading the Postscr

  • How to segment songs in iTunes?

    Hello... I've used Garageband to record all 9 chapters of my company's ebook. I plan to create both CDs and downloadable MP3s out of this recorded content. I've successfully exported my GB files to iTunes. However, I've noticed that some people are a

  • My ipad won't restore and i keep getting error code -1

    itunes indicated a problem with my ipad today and suggested restoring the ipad. THe ipad is now in receovery mode and is trying to be retored. While going through that process, it seems that it won't update more than 15% before stopping with the foll

  • Elements 10 installation

    Have downloaded the application and 7Z files but when running application an error appears saying I do not have the file archive.....please download all parts. I was only given 2 files to download. Am I missing something or are they not linked proper

  • Audio moving around within a piece?

    Ok, this is one of the weirdest things I've ever seen. We have been tweaking a feature film soundtrack for a client, going back and forth on minor adjustments over the past month or two. They called me yesterday to tell me that near the end of the fi