Hello, Sandeep : no, you are wrong running one SQL with '*' will NOT imply in hard parses : parsing in the Oracle RDBMS is based by default on the TEXT of the SQL, so if the TEXT is always the same (with * or not) , NO HARD PARSES will occur.. See :
==> Right now I have in my test database :
chiappa@TEST#1:TEST#1-DESENV:SQL>select name, value from v$sysstat where name like 'parse count%';
NAME VALUE
---------------------------------------------------------------- ---------
parse count (total) 1597177
parse count (hard) 107948
parse count (failures) 343
chiappa@TEST#1:TEST#1-DESENV:SQL>
==> I will create a .BAT scripting repeating 1000 times the l.sql script, that will send always the very same SQL text (using SELECT * but matters not) :
C:\Developers>type l.bat
FOR /L %%G IN (1,1,1000) DO sqlplus scott/tiger@wTEST#1 @l.sql
==> The l.bat script , to be repeated 1000 times :
C:\Developers>type l.sql
select * from dept;
exit
/
C:\Developers>
==> executing...
C:\Developers>l.bat
C:\Developers>sqlplus scott/tiger@wTEST#1 @l.sql
SQL*Plus: Release 10.2.0.5.0 - Production on Wed Aug 2 09:59:39 2017
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
Disconnected from Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
C:\Developers>sqlplus scott/tiger@wTEST#1 @l.sql
SQL*Plus: Release 10.2.0.5.0 - Production on Wed Aug 2 09:59:39 2017
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
Disconnected from Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
C:\Developers>sqlplus scott/tiger@wTEST#1 @l.sql
SQL*Plus: Release 10.2.0.5.0 - Production on Wed Aug 2 09:59:39 2017
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
Disconnected from Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
C:\Developers>sqlplus scott/tiger@wTEST#1 @l.sql
SQL*Plus: Release 10.2.0.5.0 - Production on Wed Aug 2 09:59:39 2017
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
Disconnected from Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
....... it will be going on and on, until execute 1000 times... After that , consulting the parse statistics system-level :
chiappa@TEST#1:TEST#1-DESENV:SQL>/
NAME VALUE
---------------------------------------------------------------- ---------
parse count (total) 1611895
parse count (hard) 107981
parse count (failures) 345
chiappa@TEST#1:TEST#1-DESENV:SQL>
===>>> see, we don´t get 1000 hard parses, not even close.... Right ? The thing about HARD PARSING in the absence of bind variables is in this line : suppose an environment where part of the SQL text to be sent to the database is 'glued' dynamically, more or less like :
v_text := 'SELECT * FROM table WHERE nameofkeycolumn = ' || variablecontaingthe value
execute v_text;
With this, if a given session pass the value 32 to the variable, the SQL text sent will be :
SELECT * FROM table WHERE nameofkeycolumn=32
Another session passing the value 45 will send :
SELECT * FROM table WHERE nameofkeycolumn=45
And so on... In THIS scenery you will fill the SQL cache area, right ??? The problem is NOT the use of '*' , BUT the fact that "SELECT * FROM table WHERE nameofkeycolumn=32" is a DIFFERENT TEXT comparing with "SELECT * FROM table WHERE nameofkeycolumn=45".. Got it ? See
https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::p11_question_id:528893984337 for more ref about it....
Another point : see the SQL executions for my example SQL text : NO childs, NO invalidations...
chiappa@TEST#1:TEST#1-DESENV:SQL>select fetches, executions, rows_processed, parse_calls, open_versions, invalidations, child_number, elapsed_time, cpu_time, kept_versions, exact_matching_signature from v$sql where sql_text = 'select * from dept';
FETCHES EXECUTIONS ROWS_PROCESSED PARSE_CALLS OPEN_VERSIONS INVALIDATIONS CHILD_NUMBER ELAPSED_TIME CPU_TIME KEPT_VERSIONS EXACT_MATCHING_SIGNATURE
---------- ---------- -------------- ----------- ------------- ------------- ------------ ------------ ---------- ------------- ------------------------
2000 1000 4000 1000 0 0 0 137534 78125 0 1.0265E+19
==> And if you are wondering about the 1000 parse calls, see
https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:2588723819082 to learn that if no hard parses are registered, thus these parse calls were SOFT PARSES....
Speaking for your need to test/simulate "ORA-04031: unable to allocate 4032 bytes of shared memory" due to , you would neeed to use some kind of DYNAMIC SQL, generating for each execution DIFFERENT SQL TEXTS : with this yes, you will have a LOT of different entries in V$SQL and alike ones....
Obvious#2 : of course, to enhance your chances in the sense of receiving ORA-4031, turn OFF automatic memory management AND have a SMALL shared pool...
Regards,
J. Laurindo Chiappa