@MySQL的存储引擎
生活随笔
收集整理的這篇文章主要介紹了
@MySQL的存储引擎
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.存儲引擎
查看MySQL提供了哪些存儲引擎
mysql> show engines; +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO | | CSV | YES | CSV storage engine | NO | NO | NO | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO | | MyISAM | YES | MyISAM storage engine | NO | NO | NO | | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL | | ARCHIVE | YES | Archive storage engine | NO | NO | NO | | InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES | | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ 9 rows in set (0.00 sec)查看MySQL當前默認的存儲引擎
mysql> show variables like '%storage_engine%'; +----------------------------+--------+ | Variable_name | Value | +----------------------------+--------+ | default_storage_engine | InnoDB | | default_tmp_storage_engine | InnoDB | | storage_engine(當前存儲引擎) | InnoDB | +----------------------------+--------+ 3 rows in set (0.00 sec)| 對比項 | MyISAM | InnoDB |
| 外鍵 | ? ? ? ? 不支持 | ? ? ? ? ? ? ? ? ? ? ? ? ? ?支持 |
| 事務 | 不支持 | ? ? ? ? ? ? ? ? ? ? ? ? ? ?支持 |
| 行表鎖 | 表鎖,即使操作一條記錄也會鎖住整張表, 不適合高并發的操作 | 行鎖,操作時只鎖定某一行,不對其他的行有影響, 適合高并發的操作 |
| 緩存 | 只緩存索引,不緩存真實數據 | 不僅緩存索引還緩存真實數據,對內存要求較高, 而且內存大小對性能有決定性影響 |
| 表空間 | ? ? ? ? ? ? ? ? ? ? ? ? 小 | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 大 |
| 關注點 | ? ? ? ? ? ? ? ? ? ? ? 性能 | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?事務 |
2.sql性能下降的原因
1).查詢語句寫的爛。
2).索引失效,可能常用的搜索字段沒有建索引。
3).關聯查詢太多的join。
4).MySQL服務器調優及各個參數的設置(緩沖,線程數等)。
3.sql的執行順序
手寫的sql
SELECT <select_list> FROM <left_table><join_type> JOIN <right_table> ON <join_condition> WHERE <where_condition> GROUP BY<group_by_list> HAVING<having_condition> ORDER BY<order_by_condition> LIMIT <limit_number>MySQL是怎么讀的呢?(從from開始讀)
FROM <left_table> ON <join_condition> <join_type> JOIN <right_table> WHERE <where_condition> GROUP BY <group_by_list> HAVING <having_condition> SELECT <select_list> ORDER BY <order_by_condition> LIMIT <limit_number>WHERE和GROUP BY是一對喲~
總結
以上是生活随笔為你收集整理的@MySQL的存储引擎的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HDU-4282 A very hard
- 下一篇: Not Equal on a Segme