SQL Performance Tuning

--Before Tuning
SELECT * FROM USER WHERE USER_NAME LIKE '%Sean%'
--After Tuning
SELECT * FROM USER WHERE USER_NAME LIKE 'Sean%'
--For OR Operator
--Before Tuning
SELECT * FROM USER WHERE USER_ID = 1 OR USER_ID = 5
--After Tuning
SELECT * FROM USER WHERE USER_ID = 1
UNION
SELECT * FROM USER WHERE USER_ID = 5
--For IN or NOT IN operators
----If it is numeric filed:
--Before Tuning:
SELECT * FROM USER WHERE USER_ID IN (1,2,3,4,6)
--After Tuning:
SELECT * FROM USER WHERE USER_ID BETWEEN (1,6) AND USER_ID!=5
----If it is string field:
USE EXISTS in a subquery

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store