我有一个 sql 查询:
select person from table t1
inner join person_history ph
on t1.person = ph.person
and t1.person not in (select person from person_history
where effective_date < '01-01-2013')
and ph.person.effective_date > '01-01-2013'
由于person_history
包含大量记录,此查询耗时过长。
如何优化此代码?