Оптимизация запроса not in (select ...

sanich_
На сайте с 24.05.2008
Offline
77
242

Добрый день.

Прошу помочь в оптимизации запроса Mysql:

select count(distinct(t.em)) as cr from

(select email as em from object where email<>''
union all
select email as em from job_list where email<>''
union all
select from_email as em from send_message where from_email<>\'\'
) as t where t.em not in (SELECT email FROM send_ignore_list_email)

Не очень быстро работает, 2.4 сек

Проблема имеено в последней выборке

as t where t.em not in (SELECT email FROM send_ignore_list_email)

Вычитал что not in можно заменить на LEFT OUTER JOIN

Сделал следующее:

select count(distinct(t.em)) as cr from

(select email as em from object where email<>''
union all
select email as em from job_list where email<>''
union all
select from_email as em from send_message where from_email<>''
) as t
LEFT OUTER JOIN send_ignore_list_email ON email=t.em where email is null

Тоже не очень быстро работает, 2.37 сек

Помогите пожалуйста

Лучший анализ бэков конкурентов - Yazzle (http://www.yazzle.ru/seo/8945eae37b4e842893f9c46afa70d80e/)

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий