Professional Documents
Culture Documents
• Performance
– Is it just about sharing SQL (or is this really a parsing talk in disguise)
• Scalability
• Security
• Do I always want to bind?
• What is bind variable peeking?
– Is it good or evil in disguise or a bit of both?
• I’m binding, but it isn’t sharing – what’s up with that?
• So the developers don't bind is cursor_sharing =
force/similar appropriate system wide?
• What is the real difference between cursor_sharing =
force/similar and which should we use under what
circumstances?
Copyright Kyte Inc. 2005
Performance
Bind02.sql
Copyright Kyte Inc. 2005
Scalability
11/10000
----------
.0011
• Does it really?
– Run bind03.sql
– Review multiuser.sql
– Findings coming right up…
• PowerEdge 2600
• 2 Xeon 3.0GHZ CPU, 512 Cache
– Really appear as 4 1.3GHz CPUs to the OS (hyper
threading)
• 2 Gig Ram
• You would expect if you are CPU bound using 1 of
4 CPUs (just parsing…) doubling the workload
would double throughput
• Up to 4 times seems reasonable.
• Not a chance….
open l_cursor for 'select * from t t' || p_job || ' where x = :x' using i;
begin
set_udump('C:\ORA4\admin\ora4\udump2'' scope=memory
utl_file_dir=''*'' scope=spfile
user_dump_dest=''C:\ORA4\admin\ora4\udump2');
end;
Copyright Kyte Inc. 2005
Security
• Over Binding
– Compulsive disorder to eradicate all literals in SQL
– Brought on by taking good advice to an illogical
extreme
Begin
for x in ( select object_name
from user_objects
where object_type in ( ‘TABLE’, ‘INDEX’ ))
loop
…
• Over Binding
– Literals in Static SQL are perfectly OK
– Problem is neither VB nor Java do Static SQL
• JSQL is considered “dead”
• So, it becomes very hard to tell what is truly variable
– Bind only that which varies
– Literals for everything else
• Always Binding
– Data warehouse – no way.
– When you run queries per second, yes.
– When you run queries that take seconds, maybe,
maybe no.
• Consider the frequency of the query
o 5,000 users running reports. Bind
o 50 users data mining. No Bind
o OLTP. Bind
o End of month report. Maybe No Bind.
o Common Sense, it is all about math
• Always Binding
– But remember SQL Injection!
– That password screen, binds
– Typical queries, binds
– Only the queries that need the advantage of literals
during optimization!
• And those have to be looked at over and over
• “user dump dest”, it seemed so simple
bvp02.sql
Copyright Kyte Inc. 2005
Bind Variable Peeking
• Similar
– When replacing the bind with a literal (reversed purposely)
could change the plan…
– Multiple child cursors will be developed
– Each can have it’s own unique plan
– Optimization will use the “best” plan
– Is this better than force?
• Depends
• More child cursors
• Longer code path
– But is does solve a little more of the problem.
similar.sql
Copyright Kyte Inc. 2005
Force/Similar
No
To setting at the system level, this is an application
level bug “workaround until we get it fixed for real” tool
Copyright Kyte Inc. 2005
Questions
and
Answers
Copyright Kyte Inc. 2005