zoukankan      html  css  js  c++  java
  • myisam_sort_buffer_size vs sort_buffer_size

    Q:

    I am MySQL on server with 6GB RAM. I need to know what is the difference between myisam_sort_buffer_size and sort_buffer_size?

    I have following size set to them:

    myisam_sort_buffer_size = 8M

    sort_buffer_size = 256M

    Please also mention if these values are fine or need adjustments?

    Thanks

    A:

    sort_buffer_size:

    MySQL documentation:

    Each session that needs to do a sort allocates a buffer of this size. sort_buffer_size is not specific to any storage engine and applies in a general manner for optimization.

    Your sort_buffer_size value seems extremely high. The default is 2M. I'd recommend going no larger than that since there is a performance penalty for going higher. Some people recommend smaller values such as 256kB. One thing to remember is this is per-client-session, it's not a global value. Large values will add up fast.

    myisam_sort_buffer_size:

    MySQL documentation:

    The size of the buffer that is allocated when sorting MyISAM indexes during a REPAIR TABLE or when creating indexes with CREATE INDEX or ALTER TABLE.

    Your myisam_sort_buffer_size seems fine. This won't be relevant unless you are rebuilding indexes using ALTER TABLE or REPAIR TABLE etc.


    sort_buffer_size:

    Each session that needs to do a sort allocates a buffer of this size. sort_buffer_size is not specific to any storage engine and applies in a general manner for optimization. See Section 8.3.1.11, “ORDER BY Optimization”, for example.

    If you see many Sort_merge_passes per second in SHOW GLOBAL STATUS output, you can consider increasing the sort_buffer_size value to speed up ORDER BY or GROUP BY operations that cannot be improved with query optimization or improved indexing. The entire buffer is allocated even if it is not all needed, so setting it larger than required globally will slow down most queries that sort. It is best to increase it as a session setting, and only for the sessions that need a larger size. On Linux, there are thresholds of 256KB and 2MB where larger values may significantly slow down memory allocation, so you should consider staying below one of those values. Experiment to find the best value for your workload. See Section C.5.4.4, “Where MySQL Stores Temporary Files”.

    The maximum permissible setting for sort_buffer_size is 4GB–1. As of MySQL 5.1.23, larger values are permitted for 64-bit platforms (except 64-bit Windows, for which large values are truncated to 4GB–1 with a warning).

    myisam_sort_buffer_size:

    The size of the buffer that is allocated when sorting MyISAM indexes during a REPAIR TABLE or when creating indexes with CREATE INDEX or ALTER TABLE.

    The maximum permissible setting for myisam_sort_buffer_size is 4GB–1. As of MySQL 5.1.23, larger values are permitted for 64-bit platforms (except 64-bit Windows, for which large values are truncated to 4GB–1 with a warning).

    myisam_max_sort_file_size:

    The maximum size of the temporary file that MySQL is permitted to use while re-creating a MyISAM index (during REPAIR TABLE, ALTER TABLE, or LOAD DATA INFILE). If the file size would be larger than this value, the index is created using the key cache instead, which is slower. The value is given in bytes.

    The default value is 2GB. If MyISAM index files exceed this size and disk space is available, increasing the value may help performance. The space must be available in the file system containing the directory where the original index file is located.

    参考:

    http://stackoverflow.com/questions/7871027/myisam-sort-buffer-size-vs-sort-buffer-size

    https://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_myisam_max_sort_file_size

  • 相关阅读:
    第七章 过滤器 Filter(二)
    第七章 过滤器基础 Filter
    学了近一个月的java web 感想
    js写的一个简单的手风琴菜单
    第六章 对象作用域与servlet事件监听器
    第五章 Web应用程序状态管理
    第四章 使用Servlet处理HTTP请求
    第三章 使用Servlet处理HTTP响应
    第二章 Servlet基础
    myeclipse解决Fail to create the java Virtual Machine
  • 原文地址:https://www.cnblogs.com/xiaotengyi/p/3603738.html
Copyright © 2011-2022 走看看