update userinfo
t1 set t1.UNIQUENO=(select t2.UNIQUENO
from property t2 where t1.mobile=t2.p_mobile
)
where exists (select 1 from property t2 where t1.mobile=t2.p_mobile
);如何优化这个sql?想实现的效果是 参照property表的UNIQUENO列,把表 userinfo中的UNIQUENO列 更新关联字段是 p_mobile=mobile;数据量大时(userinfo表数据10万以上)很慢。哪位能看看能否优化? 提供好的算法亦可!
t1 set t1.UNIQUENO=(select t2.UNIQUENO
from property t2 where t1.mobile=t2.p_mobile
)
where exists (select 1 from property t2 where t1.mobile=t2.p_mobile
);如何优化这个sql?想实现的效果是 参照property表的UNIQUENO列,把表 userinfo中的UNIQUENO列 更新关联字段是 p_mobile=mobile;数据量大时(userinfo表数据10万以上)很慢。哪位能看看能否优化? 提供好的算法亦可!
alert index [Schema].indexName disable|enable
先判断userinfo表有无UNIQUENO字段,没有就增加该列。
然后就是后面的update语句。
因为要更新的不光是userinfo,所以update语句中的表名和列名也是动态的。
这里只简写了 需要优化的地方。
索引disable可能会更慢,因为查找的速度慢了。