Mybatis 调用oracle 效率问题
写了一个function qx(uid,pid)
在某个查询语句中这样写select * from customer where delflag=1 and 1=qx(#{id});
这样会查询很慢。
create or replace function qx(uId varchar2){
return varchar2 is
hasXq varchar2(20) :='0';
adminCount number:=0;
begin
--是否是管理员
select count(*) into adminCount from user_role where user_id=uId and role_id=1;
if adminCount>0 then
hasXq:='1';
else
hasXq:='0';
end if;
return hasXq;
end;
}
若果不用函数直接这样写select * from customer where delflag=1 and 1=( select count(*)from user_role where user_id=uId and role_id=1)就很快
若果还是想用function该怎么改,才能优化查询效率