It depends on the distribution of the 4 'values' in that field.
If the cardinality is poor, then INDEX(VAL) won't be used, and they will all do 
a table scan.

> -----Original Message-----
> From: Anupam Karmarkar [mailto:sb_akarmar...@yahoo.com]
> Sent: Friday, November 16, 2012 12:36 AM
> To: mysql@lists.mysql.com
> Subject: Query Optimization
> 
> Hi All,
> 
> Consider a scenario, I have table XYZ which contains value follow BLUE RED
> GREEN NULL
> 
> following are queries we can use get this values
> 
> 1. SELECT * FROM XYX WHERE VAL IN ('BLUE','RED','GREEN'); 2. SELECT * FROM
> XYZ WHERE VAL IS NOT NULL 3. SELECT * FROM XYZ WHERE VAL = 'BLUE' OR
> VAL='RED' OR VAL='GREEN'
> and more
> 
> So which one is good in terms of optimization. I guess, 1 and 3 are similar
> in term of formation.
> 
> 
> --Anupam

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

Reply via email to