t1(id主键):
id,ip,name
1 111
2 222
3 0
4 123
5 0t2(id主键,ref_id外键对应t1.id):
id,ref_id,ip,name
1 3 444
2 3 555
3 3 523
4 5 324
4 5 323是这样的,主表是t1,记录一般都是放在t1表中的
但是当某次记录(很多条)为某种类型时,则在 t1表中插入 1条 t1.ip=0的数据,然后将这次记录插入到t2表中,用t2.ref_id与t1.id关联。
现在我想读出所有记录。
原来使用 
select
case when t1.ip=0 then t2.ip else t1.ip,
case when t1.ip=0 then t2.name else t1.name
from t1 left join t2 on t1.id=t2.ref_id 这样性能很低,t1表一般有20-30万条数据,当t2表中数据超过万的时候,读一次数据要花好长时间。
请大神给个方案。
不胜感激。