Cursor_sharing force partially parameter sql
Hi ,
We are running our application with weblogic ,jdbc thin client with Oracle 9.2.0.5 database.
We have set cursor_sharing=FORCE in init.ora.
Our problem.
Java prepared statement with partial variable substitution is not sharing cursors, All other type of executions like update using sqlplus or without prepared statement they are sharing the cursors.
For example.
1)
UPDATE t1 SET col1=? WHERE id = 123
This gets translated into
UPDATE t1 SET col1= :1 WHERE nid = 123
where as
2)
UPDATE t1 SET col1=? WHERE id = ?
It gets translated into
UPDATE t1 SET col1= :1 WHERE nid = :2
We haved 1000 of update statements run in our application as example 1)
which is not sharing cursor.
Is there any parameter we can set in database?
This is happening in 9.2.0.6 also.
<quote>Is there any parameter we can set in database?</quote>
No.
And the behavior you describe actually makes sense. If you used bind variables where you considered it to be appropriate [and conversely, didnt use them where it wasnt appropriate], why would Oracle come in and override your decision by blindingly replacing all remaining literals with binds?
<quote>We haved 1000 of update statements run in our application as example 1) which is not sharing cursor.</quote>
Then those statements have to be re-written. CURSOR_SHARING=FORCE at the instance level is supposed to be a temporary band-aid anyway
the fix is to address the underlying coding problem and revert to CURSOR_SHARING=EXACT. Maybe, just maybe
have CURSOR_SHARING other than EXACT at session level surrounding some particular piece of code deemed too risky to re-code (3rd party, undocumented, too obscure)
but some regular UPDATEs?
just fix.
Similar Messages
-
Confused about cursor_sharing=force
SQL> col name for a20
SQL> col type for a20
SQL> show parameter cursor_sharing
NAME TYPE
VALUE
cursor_sharing string
FORCE
SQL> drop table test;
Table dropped.
SQL> create table test(id int,name varchar2(100));
Table created.
SQL> insert into test select 1,object_name from dba_objects;
49794 rows created.
SQL> insert into test select object_id,object_name from dba_objects;
49794 rows created.
SQL> create index i_test_1 on test(id);
Index created.
SQL> analyze table test compute statistics for table for all indexes for all
2 indexed columns size 254;
Table analyzed.
SQL> set autot trace
SQL> select * from test where id=1;
49794 rows selected.
Execution Plan
Plan hash value: 1357081020
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 49402 | 1495K| 106 (4)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| TEST | 49402 | 1495K| 106 (4)| 00:00:02 |
Predicate Information (identified by operation id):
1 - filter("ID"=1)
Statistics
1 recursive calls
0 db block gets
3766 consistent gets
148 physical reads
0 redo size
1489087 bytes sent via SQL*Net to client
36894 bytes received via SQL*Net from client
3321 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49794 rows processed
SQL> select * from test where id=10000;
no rows selected
Execution Plan
Plan hash value: 3275607494
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Ti
me |
| 0 | SELECT STATEMENT | | 1 | 31 | 2 (0)| 00
:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TEST | 1 | 31 | 2 (0)| 00
:00:01 |
|* 2 | INDEX RANGE SCAN | I_TEST_1 | 1 | | 1 (0)| 00
:00:01 |
Predicate Information (identified by operation id):
2 - access("ID"=10000)
Statistics
0 recursive calls
0 db block gets
462 consistent gets
58 physical reads
0 redo size
325 bytes sent via SQL*Net to client
374 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed
why not choose full table scan here?????
There are no rows returned, why still have 462 consistent gets
SQL> set autot off
SQL> select sql_text,version_count from v$sqlarea where sql_text like
2 'select * from test%';
SQL_TEXT
VERSION_COUNT
select * from test where id=:"SYS_B_0"
1
oracle version :10.2.0.1
os :windows xp
Edited by: jinyu on Aug 27, 2008 10:03 PMSQL> ALTER SESSION SET NLS_LANGUAGE=AMERICAN;
Session altered.
SQL> alter system set cursor_sharing=force;
System altered.
SQL> create table test as select 1 id,object_name from dba_objects;
Table created.
SQL> insert into test select object_id,object_name from dba_objects;
49794 rows created.
SQL> commit;
Commit complete.
SQL> create index i_test_1 on test(id);
Index created.
SQL> analyze table test compute statistics for table for all indexes for all indexed columns size 25
4;
Table analyzed.
SQL> set autot trace
SQL> select * from test where id=1;
49794 rows selected.
Execution Plan
Plan hash value: 1357081020
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 49402 | 1495K| 106 (4)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| TEST | 49402 | 1495K| 106 (4)| 00:00:02 |
Predicate Information (identified by operation id):
1 - filter("ID"=1)
Statistics
1 recursive calls
0 db block gets
3768 consistent gets
4 physical reads
0 redo size
1489094 bytes sent via SQL*Net to client
36894 bytes received via SQL*Net from client
3321 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49794 rows processed
SQL> select * from test where id=10000;
no rows selected
Execution Plan
Plan hash value: 3275607494
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Ti
me |
| 0 | SELECT STATEMENT | | 1 | 31 | 2 (0)| 00
:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TEST | 1 | 31 | 2 (0)| 00
:00:01 |
|* 2 | INDEX RANGE SCAN | I_TEST_1 | 1 | | 1 (0)| 00
:00:01 |
Predicate Information (identified by operation id):
2 - access("ID"=10000)
Statistics
0 recursive calls
0 db block gets
462 consistent gets
14 physical reads
0 redo size
332 bytes sent via SQL*Net to client
374 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed
SQL> select sql_text,PLAN_HASH_VALUE,version_count,executions,parse_calls
2 from v$sqlarea where sql_text like '%select * from test%';
SQL_TEXT
PLAN_HASH_VALUE VERSION_COUNT EXECUTIONS PARSE_CALLS
EXPLAIN PLAN SET STATEMENT_ID='PLUS4294967295' FOR select * from test where id=1
1357081020 1 1 1
select * from test where id=:"SYS_B_0"
1357081020 1 2 2
EXPLAIN PLAN SET STATEMENT_ID='PLUS4294967295' FOR select * from test where id=1
0000
3275607494 1 1 1
SQL_TEXT
PLAN_HASH_VALUE VERSION_COUNT EXECUTIONS PARSE_CALLS
--------------- ------------- ---------- ----------- -
hi all,
When i set the parameter CURSOR_SHARING = FORCE, on INSERT STATEMENTS i have blank spaces added.
Ex :
INSERT INTO TABLE1(COL1)
VALUES('VALUE1');
SELECT COL1 FROM TABLE1;
Result : 'VALUE1 '
I get 'VALUES1' with spaces after...
ORACLE : 9.2.0.7
Windows 2003 Server 32 Bits
Any ideas ?
Thank you !Because datatype of COL1 is char. See below :
SQL> drop table t purge;
Table dropped.
SQL> create table t(col1 varchar2(10),col2 char(10));
Table created.
SQL> insert into t values ('aaa','xxx');
1 row created.
SQL> select * from t;
COL1 COL2
aaa xxx
SQL> select col1||col2 from t;
COL1||COL2
aaaxxx
SQL> select col2||col1 from t;
COL2||COL1
xxx aaaHTH
Girish Sharma -
Set cursor_sharing=force not work
SUNDOG315>show parameter cursor_sharing
NAME TYPE
VALUE
cursor_sharing string
EXACT
SUNDOG315>select count(*) from dba_objects where object_id=1;
COUNT(*)
0
SUNDOG315>select count(*) from dba_objects where object_id=2;
COUNT(*)
1
SUNDOG315>select count(*) from dba_objects where object_id=3;
COUNT(*)
1
SUNDOG315>select sql_text from v$sql where sql_text like 'select count(*) from d
ba_objects%';
SQL_TEXT
select count(*) from dba_objects where object_id=1
select count(*) from dba_objects where object_id=3
select count(*) from dba_objects where object_id=2
SUNDOG315>alter system set cursor_sharing=force;
系统已更改。
SUNDOG315>alter system flush shared_pool;
系统已更改。
SUNDOG315>select sql_text from v$sql where sql_text like 'select count(*) from d
ba_objects%';
未选定行
SUNDOG315>select count(*) from dba_objects where object_id=1;
COUNT(*)
0
SUNDOG315>select count(*) from dba_objects where object_id=2;
COUNT(*)
1
SUNDOG315>select count(*) from dba_objects where object_id=3;
COUNT(*)
1
SUNDOG315>select sql_text from v$sql where sql_text like 'select count(*) from d
ba_objects%';
SQL_TEXT
select count(*) from dba_objects where object_id=1
select count(*) from dba_objects where object_id=3
select count(*) from dba_objects where object_id=2
SUNDOG315>show parameter cursor_sharing
NAME TYPE
VALUE
cursor_sharing string
FORCE
Edited by: Lei Liu on Oct 20, 2010 4:44 PM
Edited by: Lei Liu on Oct 20, 2010 4:44 PMWhat is your 4 digits Oracle version ?
I cannot reproduce this even with Oracle XE:
SQL> show parameter cursor_sharing
NAME TYPE
VALUE
cursor_sharing string
FORCE
SQL>
select sql_text from v$sql where sql_text like '%dba_objects%';
SQL_TEXT
select sql_text from v$sql where sql_text like '%dba_objects%'
select count(*) from dba_objects where object_id=:"SYS_B_0"
select count(*) from dba_objects where object_id=3 -
Cursor_sharing改成force,会引起什么bug吗?
公司的数据库内有一套老的应用,跑了好多年了,但没有绑定变量,导致SQLAREA占用大量资源
我想将cursor_sharing改成force,会不会引起bug
我在此之前将此参数similar ,应用会报错
数据库版 10.2.0.4 64bit
SELECT substr(sql_text, 1, 40) "SQL", count(*), sum(executions) "TotExecs"
FROM v$sqlarea
WHERE executions < 5
GROUP BY substr(sql_text, 1, 40) HAVING count(*) > 30 ORDER BY 2 desc;
结果为
1 SELECT ………… 22625 23047
2 insert ………… 21437 21437
3 insert ………… 21429 21429
4 select ………… 19464 22630
5 delete ………… 18655 18655
6 INSERT ………… 18078 20520
7 SELECT ………… 13218 15798
8 INSERT ………… 9060 9060
9 INSERT ………… 9060 9060
10 select ………… 7870 8451
11 insert ………… 7837 8350
12 select ………… 7790 7790
13 select ………… 7789 7789
14 insert ………… 7768 7937
15 SELECT ………… 7716 9052
16 insert ………… 6636 6643
17 SELECT ………… 6392 6392
18 UPDATE ………… 6077 6439
19 SELECT ………… 6027 6389
20 update ………… 4414 4414
21 INSERT ………… 4018 40161. 不推荐在任何版本上继续使用 CURSOR_SHARING=SIMILAR
2. cursor_sharing=force 在某些特性条件下会触发bug, 主要是在低版本(9iR2,10gR2早期),具体是否触发bug取决于SQL的写法。
建议你直接参考以下 10.2.0.4上cursor_sharing的 bug list:
NB Bug Fixed Description
12862170 12.1.0.0 INSERT ALL fails with ORA-600[kkslhsh1] with CURSOR_SHARING enabled / High Version Count on HASH_MATCH_FAILED
12374212 11.2.0.3, 12.1.0.0 Assorted dump , internal errors, memory corruptions with cursor_sharing = force
12334286 11.2.0.3, 12.1.0.0 High version counts with CURSOR_SHARING=FORCE (BIND_MISMATCH and INCOMP_LTRL_MISMATCH)
11063191 11.2.0.2.7, 11.2.0.2.BP17, 11.2.0.3.2, 11.2.0.3.BP04, 12.1.0.0 ORA-4031 with hint /*+ CURSOR_SHARING_EXACT */ - excessive "KKSSP^nn" memory
10013170 11.2.0.3, 12.1.0.0 ORA-600 [736] from literal replacement with a "WAIT n" clause
9877964 11.2.0.3, 12.1.0.0 ORA-600 [19003] raised by LIKE :BIND in query
9680430 11.2.0.3, 12.1.0.0 High version count with CURSOR_SHARING = FORCE due to CBO transformation
9411496 11.2.0.2, 12.1.0.0 ORA-979 on GROUP BY query with CURSOR_SHARING set
9362218 11.2.0.2, 12.1.0.0 Literals replaced by binds when CURSOR_SHARING=EXACT
9348402 12.1.0.0 OERI [kks-hash-collision] can occur with CURSOR_SHARING=FORCE|SIMILAR
9223586 11.2.0.2, 12.1.0.0 Problems with variable length NCHAR literals with cursor sharing
9031183 11.2.0.2, 12.1.0.0 ORA-1722 with CURSOR_SHARING=SIMILAR and with NCHAR
8246445 11.2.0.2, 12.1.0.0 Query rewrite not working for multi-MV rewrite with literal replacement
5751866 11.2.0.2 Wrong Results with CASE and CURSOR_SHARING
9767674 10.2.0.5.5 Dump [kkslmtl] using CURSOR_SHARING - superceded
8794693 11.2.0.2 Dump [kkscsmtl] using literal replacement (CURSOR_SHARING)
8453245 11.2.0.1 Many child cursors with CURSOR_SHARING = FORCE
8264642 11.2.0.1 ORA-600 [kkexbindopn0] with CURSOR_SHARING = SIMILAR
7516867 10.2.0.5, 11.1.0.7.1, 11.2.0.1 Intermittent Wrong results from literal replacement with fix for bug 6163785
7272297 10.2.0.4.1, 10.2.0.5, 11.1.0.7, 11.2.0.1 Memory corruption / OERI[17114] / OERI[17125] with literal replacement
6337716 10.2.0.5, 11.1.0.7, 11.2.0.1 Wrong max column size for NULL strings with literal replacement
4071519 10.2.0.5, 11.1.0.7, 11.2.0.1 GROUP BY query with CURSOR_SHARING fails with ORA-1802
3461251 11.1.0.7, 11.2.0.1 V$SQL_SHARED_CURSOR shows all N with CURSOR_SHARING
7296258 10.2.0.5, 11.1.0.7.1 Intermittent Wrong results from literal replacement and remote objects
6163785 10.2.0.5, 11.1.0.7 Intermittent Wrong Results with dblink and cursor_sharing
8202234 Intermittent Wrong Results with dblink and cursor_sharing
4867724 10.2.0.5, 11.1.0.6 Literal replacement limits column names to 30 characters -
Force encryption on SQL Server not working?
Hello Everyone,
I'm running SQL Server 2008 64-bit. I've installed a self-signed cert on the box and set "Force Encryption" and restarted SQL server.
I setup a client machine to trust the authority of the cert installed on the server. When I connect to that SQL server from SSMS from a client machine and select the "encrypt connection" option in the client Connection properties, SSMS correctly complains
that the cert on the server does not match the computer name I asked to log into . This is because, although the cert is trusted, the dns name dos not match the CN in the cert <- Perfect, exactly what I am expecting.
When I connect to the same SQL server from the same client but UNCHECK "encrypt connection" on the client, I'm able to login. Considering I've checked the "Force Encryption" on the server, the server should have rejected the connection. Why not?
Ameer DeenHi all,
We are implementing a Merge Synchronization solution which involves three SQL Servers located on three Azure locations worldwide and one on-premises location. We need to secure communications between all servers. We are evaluating the encryption of all server
communications through SSL:
http://technet.microsoft.com/en-us/library/ms191192.aspx
When we configure one server (let’s call it server A) to accept only encrypted connections (with Force Encryption=Yes) we still can connect from other server (let’s call it server B) that do not have the certificate installed. We would expect the server
B to fail in the attempt of connect as server A should only accept encrypted communications and those should need the certificated to encrypt/decrypt everything (commands and data).
We have also review the following forum post that is very similar to this one:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/bde679d9-ff83-4fa7-b402-42e336a97106/force-encryption-on-sql-server-not-working
In all cases the Microsoft answer is:
“When the
Force Encryption option for the Database Engine is set to YES, all communications between client and server is encrypted no matter whether the “Encrypt
connection” option (such as from SSMS) is checked or not. You can check it using the following DMV statement”
When we run the provided DMV statement to check if encryption is enabled:
-- To check whether connections are encrypted between server and clients
SELECT encrypt_option
FROM sys.dm_exec_connections
We get “TRUE”. So theoretically encryption is enabled.
Then:
Why can we run SQL statements against server A from server B (with SSMS) without any certificate?
Are we wrong when we expect server A to refuse any client that do not have the right certificate?
How can server B, without any certificate, decrypt the data encrypted by server A?
Our intention is to encrypt all server in the same way so all of them will accept only encrypted communications. We are assuming that the Merge Agent will be able to communicate with the Publisher and the Subscriber through this encrypted environment. May
anyone please confirm ti?
Thanks for your help.
Best Regards
Benjamin Moles -
Multiple selection of parameter SQL error
Hi,
I am using BIP Enterprise stand alone, Release 10.1.3.2
I have a report with 2 parameters: salesperson and clientprospect with the 'multiple selection' and 'can select all' options turned on. My sql query is shown below.
When I run the report, here are the results with various parameter selection scenarios:
1-'all' select for both parameters = no results
2-any single value selected in both parameters = correct results
3-'all' select in one parameter and any single value selected in the other=no results
4-two or more values selected in either parameter=sql error ([Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Line 14: Incorrect syntax near ','.)
As the error message suggests, I looked at line 14, but there is no ',' on line 14.
Code
select RCUST.customer_name as 'Customer Name',
RCUST.customer_number as 'Customer No.',
RCUST.branch_id as 'Branch ID',
RCUST.salesperson as 'Salesperson ID',
Case tw_relshp_type
WHEN 'C' THEN 'CLIENT'
WHEN 'P' THEN 'PROSPECT'
Else 'OTHER'
END AS 'Client Type'
from dbo.TREL TREL,
dbo.RCUST RCUST
where RCUST.customer_name=TREL.tw_relshp_name
and tw_relshp_type = :ClientProspect
and salesperson = :Salesperson
order by RCUST.branch_id ASC, RCUST.salesperson ASC, RCUST.customer_name ASC
I cannot figure why I am not getting the correct results in each of the above 4 scenarios.
I seem to be stuck. I have searched this forum by keyword 'parameter', but I did not find any solutions, hence my post. Any help would be greatly apreciated.
Thanks,
HareshThanks to both of you for your prompt comments. I have tried the where...DECODE clause but I am getting the following message:
"[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]'DECODE' is not a recognized function name."
I will enter a SR in metalink. Maybe they can test and release a patch, as I suspect that this is a bug.
Haresh -
Is there anyway to force the optimizer to use a sql profile that was created?
SQL Tuning advisor has recommended to create a sql profile and after creating it, i can see that the explain plan is still not the profile.
Environment is Oracle 10g on Windows 2003.
Thanks.is there a way to force the usage of the 5GHz-network?
No, not unless the IT department will set up a separate SSID for the 5 GHz band. Then, you could set up your Mac to connect and remember that connection.
But, connecting at 5 GHz does not necessarily mean a better or faster connection. Your Mac is looking at both bands and choosing the best combination of signal strength, low noise and speed.
Since 5 GHz signals are not nearly as strong as 2.4 Ghz signals, your Mac is probably going to connect to the 2.4 GHz band, unless it is very close to the wireless router. -
YTD or Periodic ? Also the impact of Force Closing parameter
Dear expert,
I have 2 question :
1. YTDINPUT in Application Parameter :
Is there any concern if i put the parameter with Periodic ? For Example : Any function in bpc that cannot run in periodic data, maybe carry foward function?
What is the major consideration when i have to choose the periodic or ytd parameter?
2. In automatic adjustment at the business rules detail.
There is column named Force Closing.
I put the Source Flow is F0440 = ( Closing Balance Type )
I Put Destination Flow is Blank ( From what i'm read, it will write same as the Sorce Flow )
And I put The Force Closing is Check
Is that any problem with that ? Like Double data ?
Thx
SupraptoDear Wandi,
Thanks for your answer, but i think i need to be clear with my question:
For case no. 1:
I see in BPC Documentation, the recommended value in YTDInput Paramter is YTD and not periodic.
Why the recommended value is YTD ?
Out of the customer needs, what is the best pratices in bpc to store data in Legal Application , YTD or Periodic ?
Because, BPC comes with great function ( store procedure, business rules, etc ) example : business rules can set up to carry foward the value ,
If the parameter set to periodic, is the function that created in bpc will have to re-script again to make the value carry foward ?
Please see my cases not just only in carry foward case, but the consideration if the periodic is setup then what features in bpc that i have to re-create again manually in script.
For case no 2:
My service patch is 7.0.112
IF my settings is like that ? is it will create a dupplicate value ?
Because the source value is the ending balance, the destination is ending balance and the force closing is check.
From what i'm read in document, the force closing will create value in the ending value. Am I will create dupplicate data if the source value is the ending balance, the destination is ending balance and the force closing is check ?
Thanks for your help. -
Partial(?) SQL Developer Connection
Here are the symptoms:
Can only connect to SQL Express as SYS (or SYSTEM)
When using TNS, no schemas show in Network Alias dropdown
No developer-created tables (in SQL Express) can be viewed in SQL Developer connection
Environment:
Using local machine (laptop)
OS: Windows 7
SQL Developer 4
I have a feeling I'm just missing something in configuration or set-up, but am not sure. Since I cannot create a full connection to a database using Developer, it's not useful to me and I would like to use it. Because the Network Alias dropdown isn't showing me anything, I'm wondering if anything is wrong with my SQL Express installation.
Any help will be greatly appreciated.
Thanks.My apologies. I have been told that the developer forum was the incorrect place to ask help for this problem. So I marked it as answered (by direction, presumably by the moderator). In the response, I was told to pose the question in the general area, which is what I thought I was doing.
No need to apologize - we are trying to get you to the right forum for your question.
You said you are using sql developer 4 and pPart of what you said was this:
When using TNS, no schemas show in Network Alias dropdown
Oracle doesn't have any such 'Network Alias dropdown' - and 'schemas' would NOT be in a TNSNAMES.ORA file: that file has SIDs or SERVICE_IDs and is normally used with an OCI Oracle client installation. Is that dropdown something on the connection dialog in sql developer?
And when you connect as one user you won't see any tables or objects for other users unless you open the 'Other Uses' tree.
You don't need a TNSNAMES.ORA file to connect if you use 'BASIC' as the connection type. -
Partial(?) SQL Developer
Here are the symptoms:
Can only connect to SQL Express as SYS (or SYSTEM)
When using TNS, no schemas show in Network Alias dropdown
No developer-created tables (in SQL Express) can be viewed in SQL Developer connection
Environment:
Using local machine (laptop)
OS: Windows 7
SQL Developer 4
I have a feeling I'm just missing something in configuration or set-up, but am not sure. Since I cannot create a full connection to a database using Developer, it's not useful to me and I would like to use it. Because the Network Alias dropdown isn't showing me anything, I'm wondering if anything is wrong with my SQL Express installation.
Any help will be greatly appreciated.
Thanks.What is SQL Express? Since it has sys and system users, I assume you mean Oracle Express Edition. If not, you are in the wrong place.
1 Unless you created additional users in the database, that is all you can connect to. Use the Express Edition web interface to create users. I think the installation creates other users, but unless you know the passwords youwon't be able to connect.
Try "select username, accoiunt_status from dba_users;" to see what users exist and whether they are locked.
Try alter user <username> identified by <password> to change password.
Try alter user <username> account unlock to unlock accounts.
2 Unless you have a tnsnames.ora file, you won't see anything. If you are using sql developer on the same server as your database you don't really need one. Basic connection is fine.
3. Only the objects owned by the current user show up in the main part of the object browser. You need to look under the "other users" node. -
Bind variable code takes more time to complete?
Hello, My database is oracle11g.
I have same plsql code and first one is without bind variable and second one is with bind variable. Usually, bind variable should take less time. But here
the bind variable takes more time than the regular code... Can any one please explain why?
SQL> alter system flush shared_pool;
System altered.
SQL> declare
2 cursor c1 is select * from emp where rownum < 50;
3 l_start NUMBER DEFAULT DBMS_UTILITY.GET_TIME;
4 v_cnt number;
5 begin
6 for i in c1 loop
7 SELECT count(*) into v_cnt
8 FROM rate
9 WHERE rate_id IN (SELECT rate_id
10 FROM ratedetail
11 WHERE benefit_id = i.benefit_id)
12 AND effective_date =
13 TO_DATE ('2011-01-23 00:00:00', 'yyyy-MM-dd HH24:MI:SS')
14 AND rate_type_id = 1;
15 end loop;
16 DBMS_OUTPUT.PUT_LINE('total minutes....'||ROUND(ROUND((DBMS_UTILITY.GET_TIME - l_start)/100, 2)
/60,3));
17 end;
18 /
total minutes.....06
PL/SQL procedure successfully completed.
SQL> alter system flush shared_pool;
System altered.
SQL>
SQL> declare
2 cursor c1 is select benefit_id from emp where rownum < 50;
3 l_start NUMBER DEFAULT DBMS_UTILITY.GET_TIME;
4 v_cnt number;
5 begin
6 for i in c1 loop
7 execute immediate 'SELECT count(*)
8 FROM rate
9 WHERE rate_id IN (SELECT rate_id
10 FROM ratedetail
11 WHERE benefit_id = :x)
12 AND effective_date = trunc(sysdate)-202
13 AND rate_type_id = 1'
14 into v_cnt using i.benefit_id;
15 end loop;
16 DBMS_OUTPUT.PUT_LINE('total minutes....'||ROUND(ROUND((DBMS_UTILITY.GET_TIME - l_start)/100, 2)
/60,3));
17 end;
18 /
total minutes.....061
PL/SQL procedure successfully completed.
SQL>Shrinika wrote:
Thanks for the clarification.. Now i understand...
One final question on this thread before i close this thread....
My database is set to CURSOR_SHARING=FORCE for some reason. It seems somebody applied a "quick and dirty fix" to "database is slow" problem. BAD PRACTICE
My question is, when we use bind variable, does it parse the sql code every time? or does it reuse the execution plan?
In my database, it reuse the execution plan... Just checking... When we set CURSOR_SHARING=FORCE, it should generate the execution plan
for every unqiue sql code... Is that correct? Am i confusing?If by "parse" you mean a "hard parse" (which generates execution plan), then the answer is NO. As you observed, it reuses execution plan.
For e.g. with CURSOR_SHARING=FORCE setting, following SQLs
select employee_no, first_name, last_name from employees where dept_no = 10 ;and
select employee_no, first_name, last_name from employees where dept_no = 20 ;would tend to reuse the same execution plan since both of these will be rewritten by oracle (before execution) as
select employee_no, first_name, last_name from employees where dept_no = :SYS01 ;Hope this helps.
Edited by: user503699 on Aug 14, 2010 3:55 AM -
To solve ORA-1008,set cursor_sharing parameter to EXACT
Per Bug 7154579 customer, to solve ORA-1008,set cursor_sharing parameter to EXACT but still see the error on the application.
One of the instance in our 4 node RAC USED to have cursor_sharing=similar, and the rest set to exact. Customer changed it to 'exact' longtime back. but still found some background process using cursor_sharing=similar ( and still see the error 1008) .
After the bounce of the above-mentioned node, but absent a clean restart of the whole RAC database, the customer still experienced the 1008 error. Session level is showing,INSTEAD OF "SIMILAR" for the background processes,the entries of "uninitialized". See query below:
SYS@ptmpnew4 >select inst_id,id,name,value from gV$SYS_OPTIMIZER_ENV where name like 'cursor%' ;
INST_ID ID NAME VALUE
4 48 cursor_sharing exact
3 48 cursor_sharing exact
2 48 cursor_sharing exact
1 48 cursor_sharing exact
SYS@ptmpnew4 >
SYS@ptmpnew4 >select inst_id,name,value,count(1) from gV$ses_OPTIMIZER_ENV where name like 'cursor%'
group by inst_id,name,value; 2
INST_ID NAME VALUE COUNT(1)
1 cursor_sharing exact 599
1 cursor_sharing uninit 20
2 cursor_sharing exact 590
2 cursor_sharing uninit 18
3 cursor_sharing exact 583
3 cursor_sharing uninit 19
4 cursor_sharing exact 600
4 cursor_sharing uninit 18
what could be the possible reasoncursor_sharing parameter in the init. ora allows you to change the shared pool's default behaviour when parsing and caching SQL statements.
force - allows two SQL statements, which differ only by a literal value, to share parsed code cached in the shared pool. the difference in literal values must not change the meaning of the statement.
similar - allows two sql statements, which differ only by a literal value, to share parsed code cached in the shared pool. the difference in literal values must not change the meaning of the statement or its cached execution plan.
exact - two sql statements must match exactly in order to share the parse code cached in shared pool.
refer the link given below , you will get answer for all your questions.
http://www.oracle.com/technology/oramag/oracle/06-jan/o16asktom.html
to know Parsing in Oracle, refer.
http://www.databasejournal.com/features/oracle/article.php/3341851/Parsing-in-Oracle.htm
Edited by: rajeysh on Jun 19, 2010 12:40 PM -
Alternative to cursor_sharing parameter
Hello,
We presently have a 3rd party application that has an Oracle 9.2.0.8 db with statistics run on it and would like to improve performance with some bind variable queries in setting the cursor_sharing = force.
The problem is that when certain queries return a larger character set string, the apps does not accept and errors out.
Does anyone have any experience with this parameter and it's alternatives?
Much appreciated.
JRHi JR,
would like to improve performance with some bind variable queries in Cursor_sharing is a Godsend for shops with vendor SQL that cannot be changed, and for shops with ad-hoc query where literals appear in the SQL.
Does anyone have any experience with this parameter and it's alternatives?Before cursor_sharing, we made the shared_pool very tiny.
Since there was no reason to cached non-reentrant SQL, why even have a shared pool?
Obviously, the best remedy is to re-write your code to use host variables, but that's rarely a practical solution!
Also note that cursor_sharing=similar now works in 11g . . .
I have some notes here that you may find helpdul:
http://www.dba-oracle.com/t_cursor_sharing.htm
Hope this helps . . .
Donald K. Burleson
Oracle Press author
Author of "Oracle Tuning: The Definitive Reference"
http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm -
We are trying to setup a force encryption on SQL Server 2012 configuration manager and wondering if the wild card certificate works for this.
I am not if that is the issue but the cert installed on SQL server is not showing up in the dropdown of Protocols for MSSQLSERVER Propertis Certificate tab.If the Force Encryption option for the Database Engine is set to YES, all communications between client and server is encrypted no matter whether the “Encryptconnection” option is checked or not.. please
check the below links for more details..
http://blogs.msdn.com/b/dataaccess/archive/2005/08/05/448401.aspx
http://support.microsoft.com/kb/316898
-- To check whether connections are encrypted between server and clients
USE master
GO
SELECT encrypt_option FROM sys.dm_exec_connections
GO
http://www.sqlservercentral.com/blogs/basits-sql-server-tips/2012/07/16/encrypting-connections-to-sql-server/
http://technet.microsoft.com/en-us/library/ms191192.aspx
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/bde679d9-ff83-4fa7-b402-42e336a97106/force-encryption-on-sql-server-not-working?forum=sqlsecurity
Raju Rasagounder Sr MSSQL DBA
Maybe you are looking for
-
Is openDNS be an advantage to my home wireless serving all wireless devices & up internet speed and faster identification?
-
Java Runtime process, comunication with C in Linux
Hi guys, I have a project with Java GUI and C database. Basically, I need to communicate C in Java through RunTime.exec(String[] s), which returns a Process. From the Process, I can get input and output stream. My question is since Java is using unic
-
Moving Long Raw from one table to another
How to copy the record stored in a table which has Long Raw column and insert into another table The follwoing code is giving a numeric or value error declare BLOB_ID NUMBER(12); BLOB_FILE LONG RAW; Cursor c1 is select BLOB_ID , BLOB_FILE from test ;
-
I downloaded the new iTunes and now it won't connect to the Store
I downloaded the new iTunes and now it wont' connect to the store. I tried to do a repair and now I've just re-downloaded iTunes. Still no luck
-
Searching Server finds no results
I have a G5 running 10.5.8 server software and all my user machines are running 10.4.11 on G5's and mac mini's. When trying to do a file search on the connected server it yeilds zero results no matter what we type in. Even if we are typing the exact