<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        實例詳解mysql中innodb_flush_method方法

        來源:懂視網 責編:小OO 時間:2020-11-09 08:58:19
        文檔

        實例詳解mysql中innodb_flush_method方法

        innodb_flush_method的幾個典型取值。,FreeBSD.and Solaris.。如何取值,mysql官方文檔是這么建議的。
        推薦度:
        導讀innodb_flush_method的幾個典型取值。,FreeBSD.and Solaris.。如何取值,mysql官方文檔是這么建議的。

        下面小編就為大家帶來一篇innodb_flush_method取值方法(實例講解)。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

        innodb_flush_method的幾個典型取值

        fsync: InnoDB uses the fsync() system call to flush both the data and log files. fsync is the default setting.
        
        O_DSYNC: InnoDB uses O_SYNC to open and flush the log files, and fsync() to flush the data files. InnoDB does not use O_DSYNC directly because there have been problems with it on many varieties of Unix.
        
        O_DIRECT: InnoDB uses O_DIRECT (or directio() on Solaris) to open the data files, and uses fsync() to flush both the data and log files. This option is available on some GNU/Linux versions,FreeBSD, and Solaris.

        如何取值,mysql官方文檔是這么建議的

        How each settings affects performance depends on hardware configuration and workload. Benchmark
        your particular configuration to decide which setting to use, or whether to keep the default setting.
        Examine the Innodb_data_fsyncs status variable to see the overall number of fsync() calls for
        each setting. The mix of read and write operations in your workload can affect how a setting performs.
        For example, on a system with a hardware RAID controller and battery-backed write cache, O_DIRECT
        can help to avoid double buffering between the InnoDB buffer pool and the operating system's file
        system cache. On some systems where InnoDB data and log files are located on a SAN, the default
        value or O_DSYNC might be faster for a read-heavy workload with mostly SELECT statements. Always
        test this parameter with hardware and workload that reflect your production environment

        也就是說,具體的取值跟硬件配置和工作負載相關,最好做一次壓測來決定。不過通常來說,linux環境下具有raid控制器和write-back寫策略,o_direct是比較好的選擇;如果存儲介質是SAN,那么使用默認fsync或者osync或許更好一些。

        通常來說,貌似絕大部分人都取值o_direct,底層有raid卡,讀寫策略設置為write-back。在使用sysbench壓測oltp類型時,我發現o_direct確實比fsync性能優秀一些,看來適用于大部分場景,但是最近碰到一個這樣的sql,客戶反饋很慢,而在相同內存的情況下,它自己搭建的云主機執行相對快很多,后來我發現主要就是innodb_flush_method的設置值不同帶來的巨大性能差異。

        測試場景1

        innodb_flush_method為默認值,即fsync,緩存池512M,表數據量1.2G,排除緩存池影響,穩定后的結果

        mysql> show variables like '%innodb_flush_me%';
        +---------------------+-------+
        | Variable_name | Value |
        +---------------------+-------+
        | innodb_flush_method | |
        +---------------------+-------+
        1 row in set (0.00 sec)
        
        
        mysql> SELECT sql_no_cache SUM(outcome)-SUM(income) FROM journal where account_id = '1c6ab4e7-main';
        +--------------------------+
        | SUM(outcome)-SUM(income) |
        +--------------------------+
        | -191010.51 |
        +--------------------------+
        1 row in set (1.22 sec)
        
        
        mysql> SELECT sql_no_cache SUM(outcome)-SUM(income) FROM journal where account_id = '1c6ab4e7-main';
        +--------------------------+
        | SUM(outcome)-SUM(income) |
        +--------------------------+
        | -191010.51 |
        +--------------------------+
        1 row in set (1.22 sec)
        mysql> explain SELECT sql_no_cache SUM(outcome)-SUM(income) FROM journal where account_id = '1c6ab4e7-main';
        +----+-------------+---------+------+---------------+------------+---------+-------+--------+-----------------------+
        | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
        +----+-------------+---------+------+---------------+------------+---------+-------+--------+-----------------------+
        | 1 | SIMPLE | journal | ref | account_id | account_id | 62 | const | 161638 | Using index condition |
        +----+-------------+---------+------+---------------+------------+---------+-------+--------+-----------------------+
        1 row in set (0.03 sec)

        測試場景2

        innodb_flush_method改為o_direct,排除緩存池影響,穩定后的結果

        mysql> show variables like '%innodb_flush_me%';
        +---------------------+----------+
        | Variable_name | Value |
        +---------------------+----------+
        | innodb_flush_method | O_DIRECT |
        +---------------------+----------+
        1 row in set (0.00 sec)
        
        
        mysql> SELECT sql_no_cache SUM(outcome)-SUM(income) FROM journal where account_id = '1c6ab4e7-main';
        +--------------------------+
        | SUM(outcome)-SUM(income) |
        +--------------------------+
        | -191010.51 |
        +--------------------------+
        1 row in set (3.22 sec)
        
        
        mysql> SELECT sql_no_cache SUM(outcome)-SUM(income) FROM journal where account_id = '1c6ab4e7-main';
        +--------------------------+
        | SUM(outcome)-SUM(income) |
        +--------------------------+
        | -191010.51 |
        +--------------------------+
        1 row in set (3.02 sec)
        
        
        mysql> explain SELECT sql_no_cache SUM(outcome)-SUM(income) FROM journal where account_id = '1c6ab4e7-main';
        +----+-------------+---------+------+---------------+------------+---------+-------+--------+-----------------------+
        | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
        +----+-------------+---------+------+---------------+------------+---------+-------+--------+-----------------------+
        | 1 | SIMPLE | journal | ref | account_id | account_id | 62 | const | 161638 | Using index condition |
        +----+-------------+---------+------+---------------+------------+---------+-------+--------+-----------------------+
        1 row in set (0.00 sec)

        結果比較:

        兩者執行計劃一摸一樣,性能卻差距很大。在數據庫第一次啟動時的查詢結果也差距很大,o_direct也差很多(測試結果略)。不是很懂為啥這種情況下多了一層操作系統緩存,讀取效率就高了很多,生產環境設置一定要以壓測結果為準,實際效果為準,不能盲目信任經驗值。

        改進措施:

        不改變innodb_flush_method的情況下,其實這條sql還可以進一步優化,通過添加組合索引(account_id,outcome,income),使得走覆蓋索引掃描,可大大地減少響應時間

        【相關推薦】

        1. Mysql免費視頻教程

        2. MySQL中添加新用戶權限的實例詳解

        3. MySQL修改密碼和訪問限制的實例詳解

        4. 用正則表達式替換數據庫中的內容的實例詳 解

        5. php將圖片儲存mysql中的實例詳解

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        實例詳解mysql中innodb_flush_method方法

        innodb_flush_method的幾個典型取值。,FreeBSD.and Solaris.。如何取值,mysql官方文檔是這么建議的。
        推薦度:
        標簽: 方法 實例 mysql
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 三级网站在线免费观看| 456亚洲人成在线播放网站| 一道本不卡免费视频| gogo全球高清大胆亚洲| 日韩亚洲人成网站| 在线视频免费国产成人| 香蕉视频亚洲一级| 亚洲国产精品成人一区| 亚欧乱色国产精品免费视频| 怡红院亚洲怡红院首页| 日韩精品免费在线视频| 亚洲欧洲校园自拍都市| 免费精品国产日韩热久久| 亚洲熟妇av午夜无码不卡| 暖暖免费高清日本中文| 天堂亚洲免费视频| 国产∨亚洲V天堂无码久久久| 久久免费视频精品| 亚洲国产一区在线观看| 永久在线毛片免费观看| 成人特级毛片69免费观看| 国产亚洲av片在线观看16女人| 青青青国产手机频在线免费观看| 亚洲毛片免费视频| 永久免费av无码网站大全| 免费无码国产V片在线观看| 国产亚洲无线码一区二区| 亚洲精品视频免费在线观看| 亚洲AV女人18毛片水真多| 精品亚洲视频在线观看| 24小时日本韩国高清免费| 亚洲狠狠婷婷综合久久| 国精无码欧精品亚洲一区| 最近最新的免费中文字幕| 国产成人无码免费网站| 亚洲精品第五页中文字幕| 免费在线观看亚洲| 99re6在线精品视频免费播放 | 免费精品国产自产拍在线观看| 亚洲成av人在线视| 日本一线a视频免费观看|