1.首先在sql advantage执行下面的语句
set showplan on
go
察看执行是否使用到索引。
例如:
SELECT issuing.book_name ,
issuing.author ,
issuing.publisher ,
issuing.publish_date ,
issuing.isbn ,
issuing.branch ,
issuing.price ,
issuing.biblio_no ,
issuing.biblio_code ,
issuing.data_no ,
issuing.summary ,
0,
issuing.order_status ,
issuing.check_status ,
issuing.money_type
FROM mark.issuing issuing
WHERE biblio_code=‘ZD200400002‘
返回值:
QUERY PLAN FOR STATEMENT 1 (at line 1).
STEP 1
The type of query is SELECT.
FROM TABLE
mark.issuing
issuing
Nested iteration.
Table Scan. //这里显示没有使用到索引
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.
Parse and Compile Time 0.
SQL Server cpu time: 0 ms.
Table: issuing scan count 1, logical reads: (regular=2915 apf=0 total=2915), physical reads: (regular=0 apf=0 total=0), apf IOs used=0
Total writes for this command: 0
Execution Time 1.
SQL Server cpu time: 100 ms. SQL Server elapsed time: 63 ms.
(629 rows affected)
出现上面的结果后说明该检索点不是索引项,这样的话是影响检索速度的。
如果加上索引返回值应该如下。
QUERY PLAN FOR STATEMENT 1 (at line 1).
STEP 1
The type of query is SELECT.
FROM TABLE
mark.issuing
issuing
Nested iteration.
Index : idx_biblio_code
Forward scan.
Positioning by key.
Keys are:
biblio_code ASC
Using I/O Size 2 Kbytes for index leaf pages.
With LRU Buffer Replacement Strategy for index leaf pages.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.
(629 rows affected)
加了这个索引后检索速度会有所提高。
2.类似的命令还有下面几个
set statistics io on
go
set statistics time on
go
察看执行时间。
set noexec on
go
这个表示只执行查询计划,并不真正查询。