Analysis of the same Oracle SQL statement

Source: Internet
Author: User

In actual applications, to resolve the same Oracle SQL statement without repeating it, Oracle SQL statements are generally stored in the relevant memory after the first parsing. The memory in the shared buffer pool of the SGA (system global area) can be shared by all database users.

Therefore, when you execute an SQL statement (sometimes called a cursor), if it is exactly the same as the previously executed statement, oracle can quickly obtain parsed statements and the best execution path. This function greatly improves the execution performance of Oracle SQL and saves memory usage.

Unfortunately, Oracle only provides cache buffering for simple tables. This function is not applicable to multi-table join queries. The database administrator must set the appropriate parameters for this region in init. ora. When the memory area is larger, more statements can be reserved. Of course, the possibility of sharing is higher. When you submit an SQL statement to Oracle, Oracle will first find the same statement in the memory.

It should be noted that Oracle adopts a strict match between the two. To achieve sharing, the Oracle SQL statements must be identical (including spaces and line breaks ).

The shared statement must meet three conditions:

A. Character-level comparison:

The statements currently executed must be the same as those in the shared pool.

For example:

 
 
  1. SELECT * FROM EMP; 

Different from each of the following

 
 
  1. SELECT * from EMP;  
  2. Select * From Emp;  
  3. SELECT * FROM EMP;  

B. The objects referred to by the two statements must be identical:

For example:

How to access user object names

 
 
  1. Jack sal_limit private synonym   
  2. Work_city public synonym   
  3. Plant_detail public synonym   
  4. Jill sal_limit private synonym   
  5. Work_city public synonym   
  6. Plant_detail table owner 

Consider whether the following SQL statements can be shared between the two users.

C. bind variables must be used in two Oracle SQL statements)

For example, the two Oracle SQL statements in the first group are the same (which can be shared), while the two statements in the second group are different (even if different bind variables have the same value at runtime)

A.

 
 
  1. select pin , name from people where pin = :blk1.pin;   
  2. select pin , name from people where pin = :blk1.pin;  

B.

 
 
  1. select pin , name from people where pin = :blk1.ot_ind;   
  2. select pin , name from people where pin = :blk1.ov_ind;  

The above content is an introduction to the sharing of Oracle SQL statements. I hope you will gain some benefits.

Article by: http://www.programbbs.com/doc/class10-2.htm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.