Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, wallacel.

Asked: October 19, 2000 - 12:29 pm UTC

Last updated: February 28, 2007 - 3:41 pm UTC

Version: 8.1.6

Viewed 1000+ times

You Asked

Tom:

my developer didn't use bind variable in they development,
so they are lot of similar statement when i check v$sqlarea,
such as
update tableA set column1=1;
update tableA set column1=2;
update tableA set column1=3;

in version 8i, instead of ask them to rewrite they statement,
i can archive the same performance by set cursor_sharing=force.
am i right?

2.can you give me a link to the usage of CURSOR_SHARING?
i got one from your archive, but it doesn't work.

and Tom said...

Yes, cursor_sharing set to force will help this situation. It won't be as fast as if they actually used bind variables, as they should but it is better then nothing.


See chapter 19 of the "Designing and Tuning for Performance" guide for more info.

The link works -- technet just appears unavailable right this instant.


Rating

  (4 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Cursor Sharing

Rukshan Soza, May 10, 2002 - 8:03 am UTC

Tom,

Is there something similar in v805 ?.

Rgds

Rukshan

Tom Kyte
May 10, 2002 - 4:21 pm UTC

No, it is a new 8i feature.

Cursor_sharing=force & Query Output Releated Issues

Logan Palanisamy, January 20, 2003 - 3:04 pm UTC

Tom,

Thanks for all your invaluable and dedicated service.

This is with reference to page 448 of Expert One on One book. I was expecting the column length of the second query to 30 after cursor_sharing=force. But it is still coming out as 2. What could be the problem.

Connected to:
Oracle8i Enterprise Edition Release 8.1.6.3.0 - Production
With the Partitioning option
JServer Release 8.1.6.3.0 - Production

SQL> set echo on
SQL> @p448.sql
SQL> select substr(object_name, 1, 2) from dba_objects where rownum = 1;

SU
--
/1

SQL> alter session set cursor_sharing = force;

Session altered.

SQL> select substr(object_name, 1, 2) from dba_objects where rownum = 1;

SU
--
/1

SQL> exit
Disconnected from Oracle8i Enterprise Edition Release 8.1.6.3.0 - Production
With the Partitioning option
JServer Release 8.1.6.3.0 - Production
 

Tom Kyte
January 20, 2003 - 3:35 pm UTC

just an artifact -- it was already parsed. try this:

select substr(object_name, 1, 2) from dba_objects A where rownum = 1;
alter session set cursor_sharing=force;
select substr(object_name, 1, 2) from dba_objects B where rownum = 1;



Works indeed

Logan Palanisamy, January 20, 2003 - 5:38 pm UTC

SQL> select substr(object_name, 1, 2) from dba_objects A where rownum = 1;

SU
--
/1

SQL> alter session set cursor_sharing=force;

Session altered.

SQL> select substr(object_name, 1, 2) from dba_objects B where rownum = 1;

/

SUBSTR(OBJECT_NAME,1,2)
--------------------------------------------------------------------------------
/1

SQL> SQL>     
SUBSTR(OBJECT_NAME,1,2)
--------------------------------------------------------------------------------
/1

SQL> 


Thanks 

Cursor sharing for table and column aliases

Loïc, February 28, 2007 - 7:27 am UTC

Hi Tom,
I am currently facing a problem related to the use of the Hibernate ORM; my issue is detailed here: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2448

My questions are:

1/ Is there a way to share cursors having only column and/or table aliases differences?
(whatever the version of Oracle)

2/ If such a feature doesn't exist (yet?) can you think of pros and/or cons about this?

Thanks a lot in advance
Tom Kyte
February 28, 2007 - 3:41 pm UTC

1) no, they are absolutely different queries.

2) it is not feasible really.

select a X, b Y from t;
select a Y, b X from t;

you would want us to try to rewrite that 2nd query (well the first as well since we don't know if something is there already)

think of the multitude of combinations that would result.