91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MySQL內存表的缺點是什么

發布時間:2021-08-18 21:50:48 來源:億速云 閱讀:180 作者:chen 欄目:數據庫

本篇內容介紹了“MySQL內存表的缺點是什么”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

  CREATETABLE`mem_test`(`id`int(10)unsignedNOTNULLDEFAULT'0',`name`varchar(10)DEFAULTNULL,`first`varchar(10)DEFAULTNULL,PRIMARYKEY(`id`),KEY`NewIndex1`(`name`,`first`))ENGINE=MEMORY;CREATETABLE`innodb_test`(`id`int(10)unsignedNOTNULLDEFAULT'0',`name`varchar(10)DEFAULTNULL,`first`varchar(10)DEFAULTNULL,PRIMARYKEY(`id`),KEY`NewIndex1`(`name`,`first`))ENGINE=InnoDB;

  如:

  1:在=或者<=>情況下,飛快,但是在如<或>情況下,他是不使用索引

  mysql--chinastor.com-root@localhost:17db07:33:45>>explainselect*frommem_testwhereid>3;+----+-------------+----------+------+---------------+------+---------+------+------+-------------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|+----+-------------+----------+------+---------------+------+---------+------+------+-------------+|1|SIMPLE|mem_test|ALL|PRIMARY|NULL|NULL|NULL|15|Usingwhere|+----+-------------+----------+------+---------------+------+---------+------+------+-------------+1rowinset(0.00sec)mysql--chinastor.com-root@localhost:17db07:33:49>>explainselect*frominnodb_testwhereid>3;+----+-------------+-------------+-------+---------------+---------+---------+------+------+-------------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|+----+-------------+-------------+-------+---------------+---------+---------+------+------+-------------+|1|SIMPLE|innodb_test|range|PRIMARY|PRIMARY|4|NULL|7|Usingwhere|+----+-------------+-------------+-------+---------------+---------+---------+------+------+-------------+1rowinset(0.00sec)

  2:不能用在orderby情況下來提高速度

  mysql--chinastor.com-root@localhost:17db07:33:55>>explainselect*frominnodb_testorderbyid;+----+-------------+-------------+-------+---------------+---------+---------+------+------+-------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|+----+-------------+-------------+-------+---------------+---------+---------+------+------+-------+|1|SIMPLE|innodb_test|index|NULL|PRIMARY|4|NULL|15||+----+-------------+-------------+-------+---------------+---------+---------+------+------+-------+1rowinset(0.00sec)mysql--chinastor.com-root@localhost:17db07:34:27>>explainselect*frommem_testorderbyid;+----+-------------+----------+------+---------------+------+---------+------+------+----------------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|+----+-------------+----------+------+---------------+------+---------+------+------+----------------+|1|SIMPLE|mem_test|ALL|NULL|NULL|NULL|NULL|15|Usingfilesort|+----+-------------+----------+------+---------------+------+---------+------+------+----------------+1rowinset(0.00sec)

  MySQL內存表的弊端有什么

  3:不能確定倆值之間有多少行

  mysql--chinastor.com-root@localhost:17db07:37:14>>explainselectcount(1)frommem_testwhereid>3andid<6;+----+-------------+----------+------+---------------+------+---------+------+------+-------------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|extra|+----+-------------+----------+------+---------------+------+---------+------+------+-------------+|1|simple|mem_test|all|primary|null|null|null|20|usingwhere|+----+-------------+----------+------+---------------+------+---------+------+------+-------------+1rowinset(0.00sec)mysql--chinastor.com-root@localhost:17db07:40:35>>explainselectcount(1)frominnodb_testwhereid>3andid<6;+----+-------------+-------------+-------+---------------+---------+---------+------+------+--------------------------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|extra|+----+-------------+-------------+-------+---------------+---------+---------+------+------+--------------------------+|1|simple|innodb_test|range|primary|primary|4|null|1|usingwhere;usingindex|+----+-------------+-------------+-------+---------------+---------+---------+------+------+--------------------------+1rowinset(0.00sec) localhost:17db07:37:07="">>explainselect*frominnodb_testwherename='b';+----+-------------+-------------+------+---------------+-----------+---------+-------+------+--------------------------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|+----+-------------+-------------+------+---------------+-----------+---------+-------+------+--------------------------+|1|SIMPLE|innodb_test|ref|NewIndex1|NewIndex1|33|const|8|Usingwhere;Usingindex|+----+-------------+-------------+------+---------------+-----------+---------+-------+------+--------------------------+1rowinset(0.00sec)mysql--chinastor.com-root@localhost:17db07:37:10>>explainselect*frommem_testwherename='b';+----+-------------+----------+------+---------------+------+---------+------+------+-------------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|+----+-------------+----------+------+---------------+------+---------+------+------+-------------+|1|SIMPLE|mem_test|ALL|NewIndex1|NULL|NULL|NULL|20|Usingwhere|+----+-------------+----------+------+---------------+------+---------+------+------+-------------+

  當然內存表也可以手動添加btree

  CREATEINDEXBTREE_indexUSINGBTREEonmem_test(name,first)mysql--chinastor.com-root@localhost:17db03:36:41>>explainselect*frommem_testwherename='b';+----+-------------+----------+------+-----------------------+-------------+---------+-------+------+-------------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|+----+-------------+----------+------+-----------------------+-------------+---------+-------+------+-------------+|1|SIMPLE|mem_test|ref|NewIndex1,BTREE_index|BTREE_index|33|const|9|Usingwhere|+----+-------------+----------+------+-----------------------+-------------+---------+-------+------+-------------+1rowinset(0.00sec)

  哈哈,它也用到索引了。

  所以要選擇合適的存儲引擎至關重要。

“MySQL內存表的缺點是什么”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

丽江市| 逊克县| 六安市| 青岛市| 横山县| 乌鲁木齐县| 陈巴尔虎旗| 咸宁市| 谷城县| 二连浩特市| 德保县| 彭州市| 临江市| 个旧市| 崇明县| 中山市| 东乡族自治县| 江安县| 宝应县| 东源县| 同仁县| 镇坪县| 北宁市| 兰考县| 阳东县| 石门县| 灌阳县| 广河县| 贵定县| 新乡市| 大城县| 墨江| 象州县| 昌乐县| 闽侯县| 法库县| 临汾市| 嘉祥县| 贵南县| 建德市| 灵宝市|