关于hql语句中的not in和not exists
原sql语句为:v_user中的数据有6万多条
select * from v_user where usertype not in (1,2,3);
编写hql
from VUser where usertype not in (1,2,3); ————数据只有9条
结果在数据库里查询很快,但是在程序里执行很慢,前台页面卡死,相反若果是
from VUser where usertype in (1,2,3);————数据有3万多条
结果查询速度就很快,前台页面也不卡。
所以我采取用not exists查询方式
hql语句为
select t1 from VUser where not exists (select t2 from VUser where t2.usertype in (1,2,3));
结果前台页面还是卡死,请问哪位高手有其他的解决办法吗?