我认为这个查询非常有效。除了它是如此缓慢。我究竟做错了什么?一般来说,如何提高代码的速度?
<sql:query var="UserQuery" dataSource="jdbc/UBWT">
SELECT top 100
dbo.v_r_system.Name0 as PC,
dbo.v_computer_owners_preferred.User_ID as UBOCUBID,
dbo.v_r_user.User_Name0 as UBID,
dbo.v_r_user.ResourceID as ResID,
dbo.v_r_user.displayName0 as FoolName,
dbo.v_r_user.givenName0 as FirstName,
dbo.v_r_user.sn0 as LastName,
dbo.v_r_user.mail0 as eMail,
dbo.v_computer_owners_preferred.Recent_Login_TimeStamp as InFor,
dbo.v_r_user.departmentNumber0 as DeptNum,
dbo.v_r_user.department0 as Dept,
dbo.v_r_user.telephoneNumber0 as Phone
FROM
dbo.v_r_system
inner join dbo.v_computer_owners_preferred on dbo.v_r_system.name0 = dbo.v_computer_owners_preferred.computer_name
inner join dbo.v_r_user on dbo.v_computer_owners_preferred.user_id = dbo.v_r_user.unique_user_name0
where dbo.v_r_system.Name0 = ? <sql:param value="${param.ubid}" />
or dbo.v_computer_owners_preferred.User_ID = ? <sql:param value="${param.ubid}" />
or dbo.v_r_user.User_Name0 = ? <sql:param value="${param.ubid}" />
or dbo.v_r_user.displayName0 = ? <sql:param value="${param.ubid}" />
or dbo.v_r_user.telephoneNumber0 = ? <sql:param value="${param.ubid}" />
order by dbo.v_computer_owners_preferred.Recent_Login_TimeStamp desc;
我真的不喜欢所有的OR
陈述。我是否需要转换为某种准备好的语句?