中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

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

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

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

天峨县| 通江县| 枞阳县| 绥棱县| 吉安县| 始兴县| 邵武市| 卓资县| 北票市| 新源县| 武冈市| 大兴区| 儋州市| 离岛区| 潜山县| 石屏县| 克东县| 来宾市| 西昌市| 资讯| 轮台县| 乾安县| 恩平市| 宜宾市| 呼伦贝尔市| 浑源县| 绍兴县| 沛县| 长丰县| 郯城县| 辉南县| 敖汉旗| 灵寿县| 安岳县| 望江县| 峨山| 泾阳县| 漳平市| 棋牌| 红原县| 建平县|