1. 程式人生 > >利用索引與不用索引區別(profiles)

利用索引與不用索引區別(profiles)

數據庫 區別 index 示例 利用 運行 creat create set

1、定義
  對數據庫表的一列或多列的值進行排序的一種結構(Btree方式)=(相當於二分查找法)
2、優點
  加快數據檢索速度
3、缺點
  1、占用物理存儲空間
  2、當對表中數據更新時,索引需要動態維護,降低數據維護速度
4、索引示例
  1、開啟運行時間檢測 :set profiling=1;
  2、執行查詢語句
  select name from t1 where name="lucy99999";
3、查看執行時間
  show profiles;
4、在name字段創建索引
  create index name on t1(name);
5、再執行查詢語句
  select name from t1 where name="lucy88888";
6、查看執行時間
  show profiles;

利用索引與不用索引區別(profiles)