用showplan all查看使用索引成本,疑问,急救
我用showplan all 查看 表在建立索引前,和建立索引后的搜索快慢和系统消耗
下面是结果
建立前
stmttext               estimate_row estimate_io estimate_cup avg_row_size total_subtreecost
select...                  1           null         null         null          0.003289
clustered index scan...    1          0.00312       0.00016      500           0.003289
建立后
stmttext               estimate_row estimate_io estimate_cup avg_row_size total_subtreecost
select...                  1           null         null          null            0.00657
nested loop...             1           0           4.18e-6        500             0.00657
index seek...              1           0.0031      0.00016        28              0.003283
clustered index seek...    1           0.0031      0.00016        479             0.003283
是不是建立索引后总的用时为0.00657,比不建立索引用时0.003289还要久?
------解决方案--------------------索引是把双刃剑,能提高查询速度,但是牺牲硬盘空间.
不过总的原则上来说,建立索引比不建立索引好.
------解决方案--------------------你表才1行数据,搞啥啊.