Friday, 29 September 2017

SQL Query Tuning

Non-Column Expressions 
-----------------------------------
Write the query as

SELECT id, name, salary 
FROM employee 
WHERE salary < 25000;

Instead of:

SELECT id, name, salary 
FROM employee 
WHERE salary + 10000 < 35000;

Usage of DECODE to avoid multiscan
----------------------------------------------
To avoid the scanning of same rows or joining the same table repetitively. 
DECODE can also be made used in place of GROUP BY or ORDER BY clause. 

For Example: Write the query as

SELECT id FROM employee 
WHERE name LIKE 'S%' 
and location = 'Bangalore';

Instead of:

SELECT DECODE(location,'Bangalore',id,NULL) id FROM employee 
WHERE name LIKE 'Ramesh%';


No comments:

Post a Comment

Obiee CSV Export Limit Change

Issue Description: When we export a Report in CSV  format in Obiee11g, by default it will export 65,000 rows. Even if we increase the b...