Article 1: What is outline? Outline is designed to provide a stable execution plan to eliminate the impact of changes in the execution environment or object statistics. This feature is called Plan stability. In fact, outline is a collection of hint. After the query optimizer receives the SQL statement, it selects whether to use the OUTLINE logic. A. Standardize SQL statements
Article 1: What is outline? Outline is designed to provide a stable execution plan to eliminate the impact of changes in the execution environment or object statistics. This feature is called Plan stability. In fact, outline is a collection of hint. After the query optimizer receives the SQL statement, it selects whether to use the OUTLINE logic. A. Standardize SQL statements
Article 1: What is outline? Outline is designed to provide a stable execution plan to eliminate the impact of changes in the execution environment or object statistics. This feature is called Plan stability. In fact, outline is a collection of hint. After the query optimizer receives the SQL statement, it selects whether to use the OUTLINE logic. A. standardize SQL statements to remove white space and case differences B. calculate the signature c. compare the data dictionary to see if the same signature already exists. d. if yes, further compare whether SQL statements are the same (to avoid hash conflicts) e. if the SQL statement is the same, you can generate the hint related to the outline to influence the generation of the execution plan.
You can use outline at the beginning of 9i, but you can manually create outline from a cursor of the shared pool at the beginning of 10g. To use use_stored_outlines, The use_stored_outlines parameter alter system set use_stored_outlines = test must be enabled. When an SQL statement has an SQL profile and an outline, the query optimizer selects outline as limited. When to use: this technology can be used whenever a special SQL statement is optimized and cannot be modified in an application (for example, hint cannot be used. However, if hint is added and some execution plans are not used, outline is also useful. For example, if the id column is varchar2 (1) and has an index, and SQL uses where to_number (id) = 1,/* + index (t ind) */is added, outline does not have any makeup.
Article 2: Create an outline
1. create outline ALTER [SESSION | SYSTEM] SET create_stored_outlines = TRUE | class name. Example: alter session set create_stored_outlines = fwy; -- the true mode category is default. This parameter cannot be specified in the parameter file. It can only be specified manually or trigger after the database is started.
2. manually create outline 2.1 based on the text create or replace outline out_1 -- for category test on select 3 + 8 from dual;
2. Based on hash_value begin dbms_outln.create_outline (hash_value => '000000', child_number => 0 -- category => 'test'); end ;/
Article 3: querying outline select * from dba_outlines where timestamp> sysdate-1/24; -- outline select * from dba_outlines where timestamp> sysdate-5/(24*60) just created in the past hour ); -- The outline select hint created in the past five minutes from dba_outline_hints where name = 'outline _ FROM_TEXT '; -- queries the hint set of an OUTLINE.
Check whether outline is used. 1. starting from 10gR2, The dbms_xplan function looks at the execution plan and will see whether Outline 2 is used. all versions pass: execute dbms_outln.clear_used (name => 'out _ 1'); -- reset outline to use the flag select used from dba_outlines where name = 'out _ 1 '; -- display UNUSED and execute SQL select used from dba_outlines where name = 'out _ 1'; -- if used is displayed, the preceding SQL is useful to this OUTLINE.
Article 4: Change OUTLINE -- Rename outline alter outline SYS_OUTLINE_13090110433120101 rename to out2;
-- Alter outline out2 change category to default;
-- Change multiple outline categories, and replace the class TEST with default execute dbms_outln.update_by_cat (oldcat => 'test', newcat => 'default ');
-- Rebuilding the storage outline when you want query optimizer to generate a new hint set based on the new environment, you can use it. For example, when the access structure of the outline object is changed. Alter outline out_1 rebuild;
-- Query optimizer only considers the activated outline. The outline can be activated only when two conditions are met. -- first, it must be in the enable state. It is created by default. If not, you can use the following statement to change the status. Alter outline out_1 enable; alter outline out_1 disable; -- Second, the initialization parameter use_stored_outlines is activated at the session or system level. True indicates that the default category is used, false indicates that the outline is not used, or a category name is used. Alter session set use_stored_outlines = true; alter system set use_stored_outlines = true; -- this parameter can only activate one category at a time, that is, like SQL profile, a session can only use one category at a time. It is very strange that this parameter cannot be set in pfile or spfile. It can only be set after the instance system. You can also use the trigger.
Article 5: Mobile outline ----------------------------------------- vi exp. par userid = "/as sysdba" file = exp01.dmp log = exp_outline.log tables = (outln. ol $, outln. ol $ hints, outln. ol $ nodes) query = "where ol_name = 'fwy _ 3'" -------------------------------------------------------- exp parfile = exp. par -------------------------------- vi imp. par userid = "/as sysdba" file = exp01.dmp log = imp_outline.log full = y ignore = y --------------------------- imp parfile = imp. par
-- Move a single outline or a single category, and add the following statement query = "where ol_name = 'out _ 1'" query = "where category = 'test'" based on the preceding statement. For example, if the execution plan of a given SQL statement uses an index scan you want to avoid, you can delete the index in the test system and generate an Outline, and then transfer it to the production environment.
Article 6: edit the hint in outline. You cannot update the public outline in the data dictionary using some common SQL statements. It is feasible to edit the private outline. Private outline is stored in the worksheet. After creating, editing, and testing, we can publish private outline to public outline.
1. create or replace private outline out_3 on select * from dual; 1.1 create private outline p_out_1 from public out_1;
-- 10 Gb later, the default worksheet is ol $, ol $ hints, ol $ nodes under the system user, and the default three public synonyms point to them. These three tables also exist in outln, which is a table that exists as a public outline. If 9i is used, you must manually create a worksheet and a public synonym. Sqlplus '/as sysdba' alter session set current_schema = system; execute dbms_outln_edit.create_edit_tables;
Create or replace public synonym ol $ for system. ol $;
Create or replace public synonym ol $ hints for system. ol $ hints; create or replace public synonym ol $ nodes for system. ol $ nodes;
Grant select, insert, update, delete on system. ol $ to public; grant select, insert, update, delete on system. ol $ hints to public; grant select, insert, update, delete on system. ol $ nodes to public;
Once the private outline is created, you can list the Hint select hint # And hint_text from system. ol $ hints where ol_name = 'out _ 4' related to the private outline ';
-- Then use a common SQL statement to update its hint -- The hint_text of the first HINT # Is INDEX (@ "SEL $1" "T" @ "SEL $1 "(" T ". "N") -- now update ol $ hints set hint_text = 'full (@ SEL $1 T) 'Where hint # = 1 and ol_name = 'P _ OUTLINE_EDITING '; -- to ensure that the outline copy in the memory is also modified, execute dbms_outln_edit.refresh_private_outline ('out _ 1') -- then, activate and test the private outline. alter session set use_private_outlines = true; explain plan for select * from t where n = 1970; select * from table (dbms_xplan.display (null, null, 'Basic + note )')); -- If you are satisfied with private outline, you can use the following SQL statement to publish it to public outline. create public outline out_1 from private p_out_1;
Article 7 delete a storage outline delete a single drop outline out_1; Delete the entire class dbms_outln.drop_by_cat (cat => 'test'); Delete the private outline drop private outline out_1;
Article 8: OUTLINE interchange -- interchange BEFORE and AFTER outline update outln. OL $ hints set OL_NAME = DECODE (OL_NAME, 'after', 'before', 'before', 'after') WHERE OL_NAME IN ('after', 'before ');
Exec dbms_outln.update_signatures; -- Update the signature
Drop outline after; -- after replacement, you can delete unnecessary outline.
Article 9: Before 10gr1, outline cannot overwrite the initialization parameters. To use outline successfully, these initialization parameters must be consistent with the execution environment settings. Optimizer_features_enable query_rewrite_enabled star_transformation_enabled
The outline created by user A can also be used by user B without authorization. In the RAC environment, you must enable the use parameters for each instance to use OUTLINE.