Tutorial66.com
@Share Application Development Skill.



Tutorial is tutorial...66 is My Country Code Up to 10 Years EXP for Application Development Role in Thailand.
collapse

Tutorial Category



Topic: SQL Query Optimization Be careful while using conditions in WHERE clause  (Read 132 times)


My Development skill
Java JSP Servlet EJB
Spring Framework
Hibernate Framework
iReport Jasper Report
Apache CXF
PHP Codigniter
Oracle PLSQL
Unix Shell Script
when you add condition in WHERE clause be careful some SQL clause like this ..


1. Use function in where clause ..index not use
use this query for better performance :
Code: [Select]
WHERE field_name LIKE 'test%';
instead of this query:
Code: [Select]
WHERE SUBSTR(field_name,1,4) = 'test';


2. Use BETWEEN better than use logical operator
use this query for better performance :
Code: [Select]
WHERE salary BETWEEN 10000 AND 50000
instead of this query:
Code: [Select]
WHERE salary >= 10000 AND salary<= 50000


3. Use calculation in WHERE clause made query performance to down
use this query for better performance :
Code: [Select]
WHERE fname='SOMSUK' AND  lname='KASEM'
instead of this query:
Code: [Select]
WHERE fname||lname='SOMSUKKASEM'

use this query for better performance :
Code: [Select]
WHERE salary =20000
instead of this query:
Code: [Select]
WHERE salary+5000 =25000




SimplePortal 2.3.3 © 2008-2010, SimplePortal