Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: Backup & Recovery >> Plan hash value

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: Plan hash value
 Ajith  Posted: Mar 10, 2008 09:26:08 AM

 Total Post: 4
 Joined: Jan, 2008






 
All,

Could somebody explain me whether the hash values differ during execution of the same SQL with diffrent variables and during the execution with a bind var.

Thanks in advance
Ajith

 Vinod
Posted: Mar 10, 2008 10:24:36 AM  

 Total Post: 54
 Joined: Oct, 2007






 
Ajith,

Have a look on the simple demo listed below ,

SQL> create table test (
2 col1 number
3 )
4 /

Table created.

SQL> declare
begin
for i in 1..10000
loop
insert into TEST values(i);
end loop;
end;
/

PL/SQL procedure successfully completed.

SQL> select count(*) from test;

COUNT(*)
----------
10000

SQL> create index test_idx on test(col1);

Index created.

SQL> begin
dbms_stats.gather_table_stats
( user, 'TEST',
method_opt=> 'for all indexed columns size 254' );
end;
/

PL/SQL procedure successfully completed.

SQL> set autotrace traceonly explain
SQL> select * from test where col1 =10;

Execution Plan
----------------------------------------------------------
Plan hash value: 2882402178

-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 1 (0)| 00:00:01 |
|* 1 | INDEX RANGE SCAN| TEST_IDX | 1 | 3 | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

1 - access("COL1"=10)

SQL> select * from test where col1 =100;

Execution Plan
----------------------------------------------------------
Plan hash value: 2882402178

-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 1 (0)| 00:00:01 |
|* 1 | INDEX RANGE SCAN| TEST_IDX | 1 | 3 | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

1 - access("COL1"=100)

will have a look on the same using bind variable,

SQL> set autotrace on
SQL> conn test/test
Connected.
SQL> set autotrace on
SQL> variable col1 number
SQL> exec :col1 :=101

PL/SQL procedure successfully completed.

SQL> select * from test where col1=:col1;

COL1
----------
101


Execution Plan
----------------------------------------------------------
Plan hash value: 2882402178

-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 1 (0)| 00:00:01 |
|* 1 | INDEX RANGE SCAN| TEST_IDX | 1 | 3 | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

1 - access("COL1"=TO_NUMBER(:COL1))



 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar843
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Gitesh Trivedi322
  Gopu Gopi272
  neeraj sharma252
  Ramesh Jois245
  Bishal Khetan207






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software