create or replace procedure TYPE_UPDATESTATE_temp
(
TYPE_TABLE_NAME VARCHAR, --表名
TYPE_ID varchar, --id连起的字符串,例(12,13,14)
Type_State number --状态值
)
is
begin if TYPE_TABLE_NAME = 'article' then
update t_article set a_state=Type_State where instr(','||TYPE_ID||',',','||a_id||',')>0 ;
update t_article_index set ai_state=Type_State where ai_type=0 and instr(','||TYPE_ID||',',','||ai_src||',')>0;
if Type_state =5 then
update t_topic set t_list=t_list-1 where t_id in (select a_topic from t_article where a_topic>0 and instr(','||TYPE_ID||',',','||a_id||',')>0 ;
--update t_user set u_article=u_article-1 where u_id in (select a_user from a_article where a_topic>0 and instr(','||TYPE_ID||',',','||a_id||',')>0 ;
end if;
end if;
end TYPE_UPDATESTATE_temp;
数据量t_article现在30W以上,t_article_index40W以上
a_topic现在10W,t_user现在100W以上
(
TYPE_TABLE_NAME VARCHAR, --表名
TYPE_ID varchar, --id连起的字符串,例(12,13,14)
Type_State number --状态值
)
is
begin if TYPE_TABLE_NAME = 'article' then
update t_article set a_state=Type_State where instr(','||TYPE_ID||',',','||a_id||',')>0 ;
update t_article_index set ai_state=Type_State where ai_type=0 and instr(','||TYPE_ID||',',','||ai_src||',')>0;
if Type_state =5 then
update t_topic set t_list=t_list-1 where t_id in (select a_topic from t_article where a_topic>0 and instr(','||TYPE_ID||',',','||a_id||',')>0 ;
--update t_user set u_article=u_article-1 where u_id in (select a_user from a_article where a_topic>0 and instr(','||TYPE_ID||',',','||a_id||',')>0 ;
end if;
end if;
end TYPE_UPDATESTATE_temp;
数据量t_article现在30W以上,t_article_index40W以上
a_topic现在10W,t_user现在100W以上
显然在子串和源串前后都加','是多余且降低效率的
instr(TYPE_ID,a_id)中包含参数,是一个可变函数,因此不能建立函数索引。
在这么大规模的表上作update,无法使用索引只能全表扫描了。
如果硬件不是足够的强大只能修改设计了