Thursday, June 24, 2010

optimization technique in sql & pl/sql


1

Code the query as simply as possible i.e. no unnecessary columns are selected (NOT USE SELECT * FROM TABLENAME)

2

Try to avoid operations on database objects referenced in the WHERE clause (refer analysis of quries in R&D folder)

3

Using a WHERE clause helps reduce overheads in sorting, summing rather than of HAVING clause

4

Minimize the number of table lookups (subquery blocks) in queries

5

Avoid joins that require the DISTINCT qualifier on the SELECT list in queries use EXISTS

6

use union all instead of union

7

Using Anti-join condition with NOT EXIST

8

Put reserved words in upper case and application specific identifiers in lower case

9

Use whitespace inside a control statements

10

Order your declarations consistently by using datatype defined

11

For Formatting Multiline Statements parameters are align in vertically

12

Align the remainder of the assignment after the assignment operator (using :)

13

Right-align the reserved word for the clauses against the DML statement

14

Don't skimp on the use of line separators

15

The readability of code by adding white space in declaration of variables and assign values.

16

Always use parentheses in expressions containing more than one identifier or literal. .

17

Align the IN and OUT keywords in columns for procedure and functions

18

When calling a procedure or function, align the parameters into a column

19

use mixed case for user-defined identifiers

20

Code should always be indented consistently (mutile if..elseif …endif …end)

21

Statements following the WHEN clause of an exception handler should be indented five spaces

22

Spaces should precede and follow character (') literals

23

Do not leave any blank spaces preceding or following the ** operator

24

Do not leave blank spaces before or after the plus (+) and minus (-) signs when used as unary operators.

25

Identifiers should always use mixed-case and capital letters to indicate separation of elements within an identifier(vEmployee)

26

The identifiers used for explicitly declared cursors should be meaningful and also %TYPE declaration should include the datatype prefix of the identifer name

27

Do not add redundant bracketting (single if condition)

28

Use meaningful abbreviations for table and column aliases

No comments:

Post a Comment