i onun ORDER BY eklerken mysql sorgu optimize etmek çalışıyorum ama uzun zaman alır

0 Cevap php

bu benim sorgu

SELECT U.id AS user_id,C.name AS country,
                CASE
                WHEN U.facebook_id > 0 THEN CONCAT(F.first_name,' ',F.last_name)
                WHEN U.twitter_id > 0 THEN T.name
                WHEN U.regular_id > 0 THEN CONCAT(R.first,' ',R.last)
                END AS name,
                FROM user U LEFT OUTER JOIN regular R
                ON U.regular_id = R.id
                LEFT OUTER JOIN twitter T
                ON U.twitter_id = T.id
                LEFT OUTER JOIN facebook F
                ON U.facebook_id = F.id
                LEFT OUTER JOIN country C
                ON U.country_id = C.id
                WHERE (CONCAT(F.first_name,' ',F.last_name) LIKE '%' OR T.name LIKE '%' OR CONCAT(R.first,' ',R.last) LIKE '%') AND U.active = 1
                LIMIT 100

its realy fast, but in the EXPLAIN it don't show me it uses INDEXES (there is indexes). but when i add ORDER BY 'name' before the LIMIT its takes long time why? there is a way to solve it?

tablolar: Kullanıcıların 150000, düzenli 50000, facebook 50000, 50000, ülke 250 ve büyüyen twitter!

0 Cevap