11,849
社区成员
发帖
与我相关
我的任务
分享
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 a.tjlb >= '' and a.tjlb <= 'zz'
and a.gys >= '' and a.gys <= 'zz'
and b.rq >= '20130601' and b.rq <= '20130630'
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
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
-- 用到了索引,但是为毛表扫描次数还这么多,逻辑读还这么大呢。返回结果大概4000条,不到5000
Execution Time 0.
SQL Server cpu time: 0 ms. SQL Server elapsed time: 2203 ms.
执行计划:
QUERY PLAN FOR STATEMENT 1 (at line 1).
STEP 1
The type of query is EXECUTE.
Executing a newly cached statement.
QUERY PLAN FOR STATEMENT 1 (at line 1).
Executed in parallel by coordinating process and 3 worker processes.
STEP 1
The type of query is SELECT.
Executed in parallel by coordinating process and 3 worker processes.
FROM TABLE
IV_ORD_DETAIL_H
a
Nested iteration.
Index : idx_IV_ORD_DETAIL_H_rq
Forward scan.
Positioning by key.
Keys are:
rq ASC
Executed in parallel with a 3-way hash scan.
Using I/O Size 16 Kbytes for index leaf pages.
With LRU Buffer Replacement Strategy for index leaf pages.
Using I/O Size 16 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.
FROM TABLE
IV_ORD_PAY_H
b
Nested iteration.
Using Clustered Index.
Index : PK_IV_ORD_PAY_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.
Parallel network buffer merge.