Привет всем
Подскажите вот в таком вопросе
Мне надо обьединить таблицы чтобы выдать 1 целый список параметров я не до конца знаю все возможности MYSQL но возможно ли как то ускорить задачу
Вот мой запрос
SELECT ('tovar_product') AS tip,('title') AS param,(tovar_id) id FROM tovar_product WHERE tovar_fl_pokaz=1 AND tovar_fl_select=1 AND tovar_title=''
UNION ALL
SELECT ('tovar_product') AS tip,('description') AS param,(tovar_id) id FROM tovar_product WHERE tovar_fl_pokaz=1 AND tovar_fl_select=1 AND tovar_meta_desc=''
UNION ALL
SELECT ('tovar_product') AS tip,('keywords') AS param,(tovar_id) id FROM tovar_product WHERE tovar_fl_pokaz=1 AND tovar_fl_select=1 AND tovar_meta_key=''
UNION ALL
SELECT ('tovar_product') AS tip,('link') AS param,(tovar_id) id FROM tovar_product WHERE tovar_link IN (SELECT tovar_link FROM tovar_product GROUP BY tovar_link HAVING count(*)>1)
UNION ALL
SELECT ('page') AS tip,('title') AS param,(id) AS id FROM page WHERE fl_select=1 AND fl_pokaz=1 AND title=''
UNION ALL
SELECT ('page') AS tip,('description') AS param,(id) AS id FROM page WHERE fl_select=1 AND fl_pokaz=1 AND meta_desc=''
UNION ALL
SELECT ('page') AS tip,('keywords') AS param,(id) AS id FROM page WHERE fl_select=1 AND fl_pokaz=1 AND meta_key=''
UNION ALL
SELECT ('page') AS tip,('link') AS param,(id) AS id FROM page WHERE link IN (SELECT link FROM page GROUP BY link HAVING count(*)>1)
UNION ALL
SELECT ('blog') AS tip,('title') AS param,(id) AS id FROM blog WHERE fl_pokaz=1 AND fl_select=1 AND title=''
UNION ALL
SELECT ('blog') AS tip,('keywords') AS param,(id) AS id FROM blog WHERE fl_pokaz=1 AND fl_select=1 AND meta_key=''
UNION ALL
SELECT ('blog') AS tip,('description') AS param,(id) AS id FROM blog WHERE fl_pokaz=1 AND fl_select=1 AND meta_desc=''
UNION ALL
SELECT ('blog') AS tip,('link') AS param,(id) AS id FROM blog WHERE link IN (SELECT link FROM blog GROUP BY link HAVING count(*)>1)
UNION ALL
SELECT ('brends') AS tip,('title') AS param,(id) AS id FROM brends WHERE fl_select=1 AND title=''
UNION ALL
SELECT ('brends') AS tip,('keywords') AS param,(id) AS id FROM brends WHERE fl_select=1 AND meta_key=''
UNION ALL
SELECT ('brends') AS tip,('description') AS param,(id) AS id FROM brends WHERE fl_select=1 AND meta_desc=''
UNION ALL
SELECT ('brends') AS tip,('link') AS param,(id) AS id FROM brends WHERE link IN (SELECT link FROM brends GROUP BY link HAVING count(*)>1)
По факту это 4 таблицы но из них меня интересуют параметры активных записей что я отбираю по столбцам fl_select и fl_pokaz чтобы получить значения tip,param,id
На этот запрос я трачу 90 секунд, что очень много
если я делаю обработку каждой таблицы в отдельности то тратится 0,056 секунд
Везде я выставил ключи INDEX на каждый столбец в каждой таблице
И серовно не дало результата подскажите как лучше поступить в данной ситуации