标签:
http://imysql.cn/2008_09_27_deep_into_mysql_sort_buffer
http://my.oschina.net/realfighter/blog/364420
要想提高MySQL的性能,首先就是必须对mysql的配置参数进行了解,在了解了mysql的配置参数后,根据自己的项目需要以及运行环境,再做出相应的调整,那么以下这些参数是经过对mysql的官方配置参数说明、网上资料查询,以及自己的各种实验得出的个人结论。
mysql> show variables like ‘%skip%‘; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | skip_external_locking | ON |在配置文件[mysqld]下开启这个参数OK。
Each thread that does a sequential scan for a MyISAM table allocates a buffer of this size (in bytes) for each table it scans. If you do many sequential scans, you might want to increase this value, which defaults to 131072. The value of this variable should be a multiple of 4KB. If it is set to a value that is not a multiple of 4KB, its value will be rounded down to the nearest multiple of 4KB. This option is also used in the following context for all search engines: • For caching the indexes in a temporary file (not a temporary table), when sorting rows for ORDER BY. • For bulk insert into partitions. • For caching results of nested queries. and in one other storage engine-specific way: to determine the memory block size for MEMORY tables. The maximum permissible setting for read_buffer_size is 2GB. For more information about memory use during different operations, see Section 8.11.4.1, “How MySQL Uses Memory”.
This variable is used for reads from MyISAM tables, and, for any storage engine, for Multi-Range Read optimization. When reading rows from a MyISAM table in sorted order following a key-sorting operation, the rows are read through this buffer to avoid disk seeks. See Section 8.2.1.15, “ORDER BY Optimization”. Setting the variable to a large value can improve ORDER BY performance by a lot. However, this is a buffer Server System Variables 627 allocated for each client, so you should not set the global variable to a large value. Instead, change the session variable only from within those clients that need to run large queries. The maximum permissible setting for read_rnd_buffer_size is 2GB.另外可参见http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=3642777&highlight=
How many threads the server should cache for reuse. When a client disconnects, the client‘s threads are put in the cache if there are fewer than thread_cache_size threads there. Requests for threads are satisfied by reusing threads taken from the cache if possible, and only when the cache is empty is a new thread created. This variable can be increased to improve performance if you have a lot of new connections. Normally, this does not provide a notable performance improvement if you have a good thread implementation. However, if your server sees hundreds of connections per second you should normally set thread_cache_size high enough so that most new connections use cached threads. By examining the difference between the Connections and Threads_created status variables, you can see how efficient the thread cache is. For details, see Section 5.1.6, “Server Status Variables”. The default value is based on the following formula, capped to a limit of 100: 8 + (max_connections / 100) This variable has no effect for the embedded server (libmysqld) and as of MySQL 5.7.2 is no longer visible within the embedded server.
By default, the query cache is disabled. This is achieved using a default value of 1M, with a default for query_cache_type of 0. (To reduce overhead significantly if you set the size to 0, you should also start the server with query_cache_type=0. The permissible values are multiples of 1024; other values are rounded down to the nearest multiple. Note that query_cache_size bytes of memory are allocated even if query_cache_type is set to 0. See Section 8.9.3.3, “Query Cache Configuration”, for more information. The query cache needs a minimum size of about 40KB to allocate its structures. (The exact size depends on system architecture.) If you set the value of query_cache_size too small, a warning will occur, as described in Section 8.9.3.3, “Query Cache Configuration”.
0 or OFF Do not cache results in or retrieve results from the query cache. Note that this does not deallocate the query cache buffer. To do that, you should set query_cache_size to 0. 1 or ON Cache all cacheable query results except for those that begin with SELECT SQL_NO_CACHE. 2 or DEMAND Cache results only for cacheable queries that begin with SELECT SQL_CACHE.
Index blocks for MyISAM
tables are buffered and are shared by all threads. key_buffer_size
is the size of the buffer used for index blocks. The key buffer is also known as the key cache.
标签:
原文地址:http://www.cnblogs.com/zengkefu/p/5600185.html