Καλησπέρα θα ήθελα τη γνώμη σας για το παρακάτω MySQL statement.
επειδή ο πίνακας rfq_cat1 έχει πάραπολλές γραμμές με ενδιαφέρει η μέγιστη απόδοση. Γι αυτό κάτω από κάθε statement σας δίνω και το explain.
SELECT * FROM rfq_cat1 where (region = 0) limit 0,4
UNION ALL
(SELECT * FROM rfq_cat1 where (region = 10 AND country = 0) limit 0,4)
UNION ALL
(SELECT * FROM rfq_cat1 where (region = 10 AND country = 919) limit 0,4);
id select_type table type possible_keys Key Key_len ref rows Extra
1 PRIMARY rfq_cat1 ref RegionCountry_1 RegionCountry_1 1 const 1 Using where
2 UNION rfq_cat1 ref RegionCountry_1 RegionCountry_1 3 const,const 1 Using where
3 UNION rfq_cat1 ref RegionCountry_1 RegionCountry_1 3 const,const 1 Using where
NULL UNION RESULT <union1,2,3> ALL NULL NULL NULL NULL NULL
SELECT *
FROM rfq_cat1 FORCE INDEX (RegionCountry_1)
where (region = 0) OR (region = 10 AND country = 0) OR (region = 10 AND country = 919)
limit 0,10;
id select_type table type possible_keys Key Key_len ref rows Extra
1 SIMPLE rfq_cat1 range RegionCountry_1 RegionCountry_1 3 NULL 3 Using where
το index είναι περιλαμβάνει το region,country...
Θέλω να ξέρω αν είναι πιο αποδοτικό το να χρησιμοποιήσω unions ή OR...
Ευχαριστώ προκαταβολικά.