MySQL table_cache优化(二)_MySQL
bitsCN.com
table_cache指定表高速缓存的大小。每当MySQL访问一个表时,如果在表缓冲区中还有空间,该表就被打开并放入其中,这样可以更快地访问表内容。通过检查峰值时间的状态值Open_tables和Opened_tables,可以决定是否需要增加table_cache的值。如果你发现open_tables等于table_cache,并且opened_tables在不断增长,那么你就需要增加table_cache的值了(上述状态值可以使用SHOW STATUS LIKE ‘Open%tables’获得)。注意,不能盲目地把table_cache设置成很大的值。如果设置得太高,可能会造成文件描述符不足,从而造成性能不稳定或者连接失败。
www.itcankao.cn
首先是MyISAM:
从官方网站上面看,每个线程会独自持有一个数据文件的文件描述符,而索引文件的文件描述符是公用的。当table cache不够用的时候,MySQL会采用LRU算法踢掉最长时间没有使用的表。如果table_cache设置过小,MySQL就会反复打开、关闭 frm文件,造成一定的性能损失。那么,table_cache设置是不是越大越好呢?从table_cache negative scalability 这篇文章的测试可以看出,如果table_cache设置过大,MySQL将会消耗很多CPU去做 table cache的算法运算(具体是哪个算法目前不清楚,有可能是LRU)。因此table_cache的值一定要设置合理,没事多看一看 opened_tables参数,如果一直增长的话,就需要适当增加table_cache的值了。
接着是InnoDB:
InnoDB的元数据管理是放在共享表空间里面做的,所以获取表的结构不需要去反复解析frm文件,这是比MyISAM强的地方。即使 table_cache设置过小,对于InnoDB的影响也是很小的,因为它根本不需要反复打开、关闭frm文件去获取元数据。 根据How innodb_open_files affects performance这篇文章的测试可以看出,table_cache和 innodb_open_files的大小对InnoDB效率的影响比较小。但是在InnoDB crash的情况下, innodb_open_files设置过小会影响recovery的效率。所以用InnoDB的时候还是把 innodb_open_files放大一些比较合适。 bitsCN.com

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The function is to provide engineers with feedback on usage information and records to facilitate problem analysis (used during development); because users themselves do not often generate upload logs, they are useless to users. The logging buffer is a small, temporary area used for short-term storage of change vectors for redo logs to be written to disk. A log buffer write to disk is a batch of change vectors from multiple transactions. Even so, the change vector in the log buffer is written to disk in near real-time, and when the session issues a COMMIT statement, the log buffer write operation is performed in real time.

Hello everyone, today let us talk about Linux zero-copy technology. We will use the sendfile system call as an entry point to deeply explore the basic principles of zero-copy technology. The core idea of zero-copy technology is to minimize the copying of data between memories and improve the efficiency and performance of data transmission by optimizing the data transmission path. 1. Introduction to zero-copy technology Linux zero-copy technology is a technology used to optimize data transmission. It improves the efficiency of data transmission by reducing the number of data copies between kernel mode and user mode. During the process of data transmission, it is usually necessary to copy the data from the kernel buffer to the application buffer, and then from the application buffer to the buffer of the network device before the transmission can be completed. Advantages of zero-copy technology

Title: Statements and specific code examples for viewing table data in MySQL MySQL is an open source relational database management system that is widely used in applications of all sizes. In MySQL, viewing table data is a very basic operation. The following will introduce how to implement this operation through specific statements and code examples. First, we will introduce the statements and specific code examples for viewing table data through the MySQL command line tool. Suppose we have a table named "employees", the following is the pass

File read and write performance in Golang can be optimized by using buffers: buffers store data read or written from disk, thus reducing the number of disk operations. Examples of read and write functions using buffers: readFileBuffered and writeFileBuffered. Actual case: Using buffers can reduce the number of disk operations for a 1GB file from 1,000,000 to 1,024. Using buffering technology improves application efficiency when processing large files.

MySQL is a commonly used relational database management system that supports the operation of renaming tables. Normally, renaming a table carries certain risks, so you should be very careful when performing this operation. In this article, we will explore how to implement the rename table statement in MySQL and provide detailed code examples. In MySQL, you can use the ALTERTABLE statement to rename a table. The following is the basic syntax of the ALTERTABLE rename statement: ALTERTABLEo

In the Oracle database, setting read-only permissions on tables is a very important operation, which can protect data security and prevent misoperations. The following will introduce how to set read-only permissions on tables in an Oracle database and provide specific code examples. First, we need to understand that in the Oracle database, users obtain permissions on tables through authorization. Table permissions include SELECT (query), INSERT (insert), UPDATE (update) and DELETE (delete) operations. Here we will introduce

How to adjust the buffer size of MySQL MySQL is a commonly used relational database management system that is widely used in various types of applications. When using MySQL, adjusting its buffer size is an important optimization measure that can improve the performance and response speed of the database. This article will introduce how to adjust the buffer size of MySQL and give relevant code examples. InnoDB buffer pool InnoDB is a storage engine of MySQL that uses a memory area called a "buffer pool" to provide

A Microsoft computer case is a case used to protect your computer. It not only provides additional protection but also adds a decorative effect. For those who want to add some personalized elements to their computers, Microsoft computer cases are an ideal choice. The Microsoft Computer Case Recommended Configuration Table is a detailed table that lists the recommended configurations for different models and specifications of Microsoft computer cases. We will introduce the recommended configuration table of Microsoft computer cases in detail and explain some aspects of it. 1. Applicable models In the recommended configuration table, the first thing to consider is the applicable models of Microsoft computer cases. Different models of Microsoft computer cases may have different sizes and shapes, so you need to choose the appropriate case according to your computer model. The configuration table lists the microcontrollers applicable to different models.
