我有一个像这样的查询:
select row_number() over(order by m_time desc) as row, m.m_id, m_time, m_log_id
(case when exists(select 1 from t_approved_phonenumber where phone_number = m.c_phone_number) then 1 else 0 end) as approved,
(case when exists(select 1 from t_log log where log.c_id < m.m_log_id and log.phone_number = m.phone_number) then 'N' else 'Y' end) as is_first_time
from t_message m
所有表 t_approved_phonenumber、t_message 和 t_log 都有很多记录。并且所有的 ID 都是主键,phone_number 列有索引。有时我的查询很慢。有什么办法可以加快速度吗?
谢谢,