Vous êtes sur la page 1sur 5

Some Concrete Examples For MD.

40 performance improvement
Suggestions
Sql is a tool which is used by us .Coding In this needs a conversion when we run this
in Oracle . The first thing to be kept in mind is allowing the continuous usage of parsed SQ
statements . The use of the same can be facilitated in we maintain a O!"#TO#O!"
correspondence of the statements between SQ and Oracle
Please Follow the here under for allowing Parsed Statements
$%SQ cannot be shared within Oracle unless it is absolutely identical. Statements must have
match e&actly in case' white space and underlying schema ob(ects to be shared within Oracle)s
memory. Oracle avoids the parsing step for each subsequent use of an identical statement.
sql* S""CT !+," -.O, ",/ 01"." ",/%I2 3 4$45
statement to
match
sql* S""CT !+," -.O, emp 01"." ",/%I2 3 4$45 lower case
sql* S""CT !+," -.O, ",/ 01"." ",/%I234$45 white space
sql* S""CT !+,"
-.O, S%C6STO,".
01"." ",/%I234$45
white space

6se SQ standards within an application. .ules like the following are easy to implement and
will allow more sharing within Oracle)s memory.

# 6sing a single case for all SQ verbs
# 7eginning all SQ verbs on a new line
# .ight or left aligning verbs within the initial SQ verb
# Separating all words with a single space

If you have a 01"." clause that includes e&pressions connected by two or more +!2
operators' SQ Server will evaluate them from left to right in the order the are
written. This assumes that no parenthesis have been used to change the order of e&ecution.
7ecause of this' you may want to consider one of the following when using +!28
!ocate the least li"el true #$D expression first. This way' if the +!2 e&pression is false'
the clause will end immediately' saving time.

If both parts of an +!2 e&pression are equally likely being false' put the least complex
#$D expression first. This way' if it is false' less work will have to be done to evaluate the
e&pression.
9ou may want to consider using Query +naly:er to look at the e&ecution plans of your queries
to see which is best for your situation
%f ou find that S&! Server uses a '#(!E SC#$ instead of an %$DE) SC#$
when ou use an %$ or *+ clause as part of our ,-E+E clause' even when
those columns are covered by an inde&' consider using an inde& hint to force the
Query Optimi:er to use the inde&.
-or e&ample8
SELECT * FROM tblEmployee WHERE emp_no = 1 AND emp_id IN !"#$"%&'
takes about ; seconds' while8
SELECT * FROM tblemployee INDE( = I(_ID')* t*i+ i+ , -.+tom inde/ *)
WHERE emp_no = 1 AND emp_id IN !"#$"%&'
-omplete+ 0it*in ,n +e-ond
1
T*e2e i+ , -ontin.o.+ .+,3e o4 IS (NOT) NULL -omp,2i+on in t*e
-ode+
Repl,-e t*e .+e o4 i+ N.ll by t*e .+e o4 S5L inb.ilt 4.n-tion
len3t*
T*e len3t* -omp,2i+on o4 t.ple 6,l.e le++ t*,n 1 i+ e7.i6,lent to
IS N8LL -omp,2i+on9I4 b.+ine++ lo3i- i+ bein3 *,mpe2ed t*en
+imply :.n-* len3t* 4.n-tion 0it*in N;L 9
E/,mple
S,y in , 0*e2e -l,.+e yO. *,6e t*e Filte2
<<<<<<<<<<<<<99 W*e2e emp_lo-,tion IS N8LL
)* 2epl,-e it by *) LEN=TH emp_lo-,tion' > 1
)* :.n-* 0it* N;L e/,mple *)
N;Llen3t*emp_lo-,tion'"1' = 1'
Do Not Use Use
SELECT account_name, trans_date, amount
FROM transaction
WHERE SUBSTR(account_name,1,7) =
'CAPITAL'
SELECT account_name, trans_date,
amount
FROM transaction
WHERE account_name LIKE
'CAPITAL'
SELECT account_name, trans_date, amount
FROM transaction
WHERE account_name !! account_t"#e =
'AME!A'
SELECT account_name, trans_date,
amount
FROM transaction
WHERE account_name $
'A%E&'
AND account_t"#e $ 'A''
SELECT account_name, trans_date, amount
FROM transaction
WHERE amount ($ )'
SELECT account_name, trans_date,
amount
FROM transaction
WHERE amount * )'
SELECT account_name, trans_date, amount
FROM transaction
WHERE amount +* )'
SELECT account_name, trans_date,
amount
FROM transaction
WHERE amount * )'
Repl,-ement 4o2 H,6in3
SELECT re"ion, A#$ %&oc_si'e(
FROM &ocation
$RO)P *+ re"ion
,A-IN. re"ion = 'S+,-E+'
A-, re"ion = 'PERTH'
SELECT re"ion, A#$ %&oc_si'e(
FROM &ocation
/,ERE re"ion = 'S+,-E+'
A-, re"ion = 'PERTH'
$RO)P *+ re"ion
?oin+ *,6in3 di+tin-t 7.,li4ie2
SELECT DISTINCT 0e#t_no,
0e#t_name
FROM de.t ,,
em. E
WHERE ,/de.t_no = E/de.t_no
SELECT de.t_no, de.t_name
FROM de.t ,
WHERE E&ISTS %
SELECT '!'
FROM em. E
WHERE E/de.t_no =
,/de.t_no(

8+,3e o4 8nion ,nd 8nion ,ll
SELECT acct_num, 0a&ance_amt
FROM de0it_transactions
WHERE tran_date = '123,EC345'
UNI1N
SELECT acct_num, 0a&ance_amt
FROM credit_transactions
WHERE tran_date = '123,EC345'
SELECT acct_num, 0a&ance_amt
FROM de0it_transactions
WHERE tran_date = '123,EC345'
UNI1N ALL
SELECT acct_num, 0a&ance_amt
FROM credit_transactions
WHERE tran_date = '123,EC345'
N@ T*e Step+ ,bo6e 3i6e only +.33e+tion9 In3enio.+ .+e o4 o.2
p2o32,mmin3 lo3i- i+ needed

Vous aimerez peut-être aussi