2,596
社区成员
发帖
与我相关
我的任务
分享
各位看看这语句有没有办法优化啊
set statistics io on
set statistics time on
select a.gys,'','','',b.str,'',b.kindid,b.kh,b.payje,null,a.gdsid,'',a.barcode,a.tjlb,'',b.rq,b.dh,b.djlx,''
from IV_ORD_DETAIL_H a ,IV_ORD_PAY_H b
where a.djlx= b.djlx and a.syjh = b.syjh and a.dh = b.dh and a.str = b.str and a.rq =b.rq
and a.str >= '' and a.str <= 'zz'
and b.rq >= '20130601' and b.rq <= '20130630'
and a.tjlb >= '' and a.tjlb <= 'zz'
and a.gys >= '' and a.gys <= 'zz'
and b.is_zkq='Y' and a.str2 <> 'Z007'
and b.kindid like '%'
and b.kindid <> '9001' and a.sn=10
--索引情况:
sp_helpindex IV_ORD_PAY_H
--PK_IV_ORD_PAY_H clustered, unique located on default str, rq, dh, syjh, djlx, sj, sn, rowno
走了嵌套循环连接。
QUERY PLAN FOR STATEMENT 1 (at line 2).
STEP 1
The type of query is SELECT.
4 operator(s) under root
|ROOT:EMIT Operator (VA = 4)
|
| |NESTED LOOP JOIN Operator (VA = 3) (Join Type: Inner Join)
| |
| | |RESTRICT Operator (VA = 1)(0)(0)(0)(6)(0)
| | |
| | | |SCAN Operator (VA = 0)
| | | | FROM TABLE
| | | | IV_ORD_PAY_H
| | | | b
| | | | Using Clustered Index.
| | | | Index : PK_IV_ORD_PAY_H
| | | | Forward Scan.
| | | | Positioning by key.
| | | | Keys are:
| | | | str ASC
| | | | rq ASC
| | | | Using I/O Size 16 Kbytes for data pages.
| | | | With LRU Buffer Replacement Strategy for data pages.
| |
| | |SCAN Operator (VA = 2)
| | | FROM TABLE
| | | IV_ORD_DETAIL_H
| | | a
| | | Using Clustered Index.
| | | Index : PK_IV_ORD_DETAIL_H
| | | Forward Scan.
| | | Positioning by key.
| | | Keys are:
| | | str ASC
| | | rq ASC
| | | dh ASC
| | | syjh ASC
| | | djlx ASC
| | | Using I/O Size 4 Kbytes for data pages.
| | | With LRU Buffer Replacement Strategy for data pages.
IO情况:
Table: IV_ORD_DETAIL_H scan count 3, logical reads: (regular=14735 apf=0 total=14735), physical reads: (regular=0 apf=0 total=0), apf IOs used=0
Table: IV_ORD_PAY_H scan count 66292, logical reads: (regular=272884 apf=0 total=272884), physical reads: (regular=0 apf=0 total=0), apf IOs used=0
Total writes for this command: 0
Execution Time 0.
SQL Server cpu time: 0 ms. SQL Server elapsed time: 2203 ms.