如何提高页面加载速度以尽早获取数据?
select B.bdregno, B.srno, B.bdbillno, B.bdfees as bdfees, B.bdqty as bdqty,
B.bdrcode as bdrcode, B.bdtno as bdtno, B.bdvdate as bdvdate, T.TNAME as TNAME
from dbo.[test] T full outer join
dbo.[billdet] B
on T.TCODE = B.bdtcode
where" + qr + " bdregno='" + hdfregno.Value + "'
order by bdvdate asc, srno
查询在SQL Server中快速运行,但是在ASP.NET应用程序中,加载页面大约需要25秒。
答案 0 :(得分:1)
首先,我怀疑您是否真的想要完全外部联接。我猜一个left join
就足够了:
select B.bdregno, B.srno, B.bdbillno, B.bdfees, B.bdqt,
B.bdrcode, B.bdtno, B.bdvdate, T.TNAME
from dbo.[billdet] B left join
dbo.[test] T
on T.TCODE = B.bdtcode
where b.bdregno = ? --'" + hdfregno.Value + "'
order by b.bdvdate asc, srno
对于此查询,您希望在billdet(bdregno, bdtcode)
上建立索引。引擎仍然需要做麦芽汁。
请注意,您应该将值作为参数传入,而不要查询字符串。