![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
#12
| |||
| |||
|
|
SQL> declare 2 sqltext clob; 3 spm_op pls_integer; 4 begin 5 sqltext := 'select * from t1'; 6 spm_op := 7 dbms_spm.load_plans_from_cursor_cache 8 (sql_id = 'an6t9h9g5s3vh', 9 plan_hash_value => 646159151, 10 sql_text => sqltext); 11 end; 12 / PL/SQL procedure successfully completed. |
#13
| |||
| |||
|
#14
| ||||||||
| ||||||||
|
|
No need to add the dbms_output. You can see from the dbms_xplan output in my demo that it worked - the select wasn't using a FTS and after the load is reported as using the baselined plan from the other statement. If I do add the output then then I get "1 plans loaded from the cursor cache'. I've uploaded an end-to-end test + output there that works in 11.2.0.2. Can you post something similar showing it not working? From what you posted previously, and as explained in my post above, what you were doing previously was wrong - you can't call load_plans_from_cursor_cache with the sql_id of a target statement and the plan_hash_value of a source statement. That's not how it works. Cheers, Dominic |
|
Id | Operation | Name | Rows | Bytes | Cost (% CPU)| Time |
|
0 | SELECT STATEMENT | | | | 1 (100)| 1 | SORT AGGREGATE | | 1 | 1 | | * 2 | INDEX RANGE SCAN| BIG_TABLE_FCHAR | 2 | 2 | 1 (0)| 00:00 |
|
Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | |
|
0 | SELECT STATEMENT | | | | 66 (100)| | 1 | SORT AGGREGATE | | 1 | 1 | | * 2 | TABLE ACCESS FULL| BIG_TABLE | 2 | 2 | 66 (8)| 00:00:01 | |
|
Id | Operation | Name | Rows | Bytes | Cost (% CPU)| Time |
|
0 | SELECT STATEMENT | | 1 | 1 | 1 (0)| 00:00 |
|
1 | SORT AGGREGATE | | 1 | 1 | | * 2 | INDEX RANGE SCAN| BIG_TABLE_FCHAR | 2 | 2 | 1 (0)| 00:00 |
#15
| |||
| |||
|
|
SQL_ID *6tm6vjxx9wwp9, child number 0 select count(*) from big_table where first_char='Z' Plan hash value: 889699537 SQL_ID *9h20pt9r130ck, child number 0 select /*+ full(big_table) */ count(*) from big_table where first_char='Z' Plan hash value: 599409829 Next, the goal of the exercise: use the SQL_ID and the text of the first statement and the plan hash value of the second(hinted) statement. It obviously doesn't work. declare v_sql_text CLOB := * * 'select count(*) from big_table where first_char=''Z'''; v_sql_id varchar2(13) := '6tm6vjxx9wwp9'; v_hash number := 599409829; plans_loaded number; begin * * plans_loaded:=dbms_spm.load_plans_from_cursor_cach e( * * * * sql_id => v_sql_id, * * * * plan_hash_value=>v_hash, * * * * sql_text => v_sql_text); * * dbms_output.put_line('Loaded '||plans_loaded||' plans.'); end; *14 */ |
#16
| |||
| |||
|
#17
| |||||
| |||||
|
|
For the target statement, you don't need anything else but the sql text. No sql id. Nothing. Because the sql text is run through something like dbms_sqltune.sqltext_to_signature. Signature is the key for baselines - no sql id, no hash value, etc. |
|
Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | |
|
0 | SELECT STATEMENT | | 1 | 1 | 66 (8)| 00:00:01 | 1 | SORT AGGREGATE | | 1 | 1 | | * 2 | TABLE ACCESS FULL| BIG_TABLE | 2 | 2 | 66 (8)| 00:00:01 | |
|
Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | |
|
0 | SELECT STATEMENT | | 1 | 1 | 66 (8)| 00:00:01 | 1 | SORT AGGREGATE | | 1 | 1 | | * 2 | TABLE ACCESS FULL| BIG_TABLE | 2 | 2 | 66 (8)| 00:00:01 | |
#18
| |||
| |||
|
|
P.S. I provided a complete end-to-end demo in my post above that worked. Wouldn't the easiest thing to have done be to run that verbatim and show that it did not work? |
#19
| |||
| |||
|
|
On Wed, 12 Oct 2011 12:46:13 -0700, dombrooks wrote: P.S. I provided a complete end-to-end demo in my post above that worked. Wouldn't the easiest thing to have done be to run that verbatim and show that it did not work? Some people never learn. Thanks for helping me out. The mistake was conceptual. |
![]() |
| Thread Tools | |
| Display Modes | |
| |