MySQL监控性能的一些方法总结
---首先, Oracle中的逻辑读对应物理读的概念,是在利用数据缓存区的技术上,对数据访问次数的计数分类。---物理读,真正有IO;逻
---首先, Oracle中的逻辑读对应物理读的概念,是在利用数据缓存区的技术上,对数据访问次数的计数分类。
---物理读,真正有IO;逻辑读,是从缓存区读到数据,可以考察缓存区的命中率,但只是某个具体对象在缓存区中的命中率。
---所以,使用数据缓存区技术的,都可以有类似的方式。但是,这仅是从IO的角度去衡量数据库的性能的。即不完全可靠。
---其次,MySQL提供了一些方式,用以考察IO的使用情况。
---MySQL方式1:区分“索引读”还是“随机读”。这种情况,不从缓存区的角度出发,是从单表扫描数据的方式的角度出发的。
---所以,可以采用如下方式辅助判断:
mysql> show status like 'handler_read%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| Handler_read_first | 0 |
| Handler_read_key | 2 |
| Handler_read_last | 0 |
| Handler_read_next | 0 |
| Handler_read_prev | 0 |
| Handler_read_rnd | 0 |
| Handler_read_rnd_next | 0 |
+-----------------------+-------+
7 rows in set (0.00 sec)
---MySQL方式2:通过状态变量了解服务器整体状况
---通过show status和应用特点了解各种sql的执行频率
---通过show status可以提供服务器状态信息,如以下几个参数对MyISAM和Innodb存储引擎都计数:
1、com_select:执行select操作的计数,一次查询只累加1;
2、com_insert:执行insert操作的次数,对于批量插入的insert操作,只累加一次;
3、com_update:执行update操作的次数;
4、com_delete:执行delete操作的次数;
---以下几个参数是针对Innodb存储引擎计数的,累加的算法也略有不同:
1、Innodb_rows_read:查询返回的行数,不仅是select操作,,delete和update也会触发对元组的读操作;
2、Innodb_rows_inserted:执行insert操作插入的行数;
3、Innodb_rows_updated:执行update操作更新的行数;
4、Innodb_rows_deleted:执行delete 操作删除的行数;
通过以上几个参数,使用show status 命令查看参数值,就可以很容易了解当前数据库的应用是以插入更新为主还是查询操作为主,对于更新操作的计数,是对执行次数的计数,不论成功提交还是回滚都会累加。
对于事务型的应用,可以通过com_commit和com_rollback可以了解事务提交和回滚的情况,对于回滚操作非常频繁的数据库,可能意味着存在应用编写问题。
---MySQL方式3:通过PFS(Performance Schema)了解服务器整体状况/IO状况
1、The MySQL Performance Schema is a feature for monitoring MySQL Server execution at a low level.
2、The Performance Schema monitors server events. An “event” is anything the server does that takes time and has been instrumented so that timing information can be collected. In general, an event could be a function call, a wait for the operating system, a stage of an SQL statement execution such as parsing or sorting, or an entire statement or group of statements. Currently, event collection provides access to information about synchronization calls (such as for mutexes) file and table I/O, table locks, and so forth for the server and for several storage engines.
3、这个功能很强大, 请大家注意掌握. 内容多我们不一一说明,可以参考官方手册的performance-schema.htm文件. 他必定要成为MySQL监控的主流.
--------------------------------------分割线 --------------------------------------
Ubuntu 14.04下安装MySQL
《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF
Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL
Ubuntu 14.04下搭建MySQL主从服务器
Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群
Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb
MySQL-5.5.38通用二进制安装
--------------------------------------分割线 --------------------------------------
本文永久更新链接地址:

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

PHP is a back-end programming language widely used in website development. It has powerful database operation functions and is often used to interact with databases such as MySQL. However, due to the complexity of Chinese character encoding, problems often arise when dealing with Chinese garbled characters in the database. This article will introduce the skills and practices of PHP in handling Chinese garbled characters in databases, including common causes of garbled characters, solutions and specific code examples. Common reasons for garbled characters are incorrect database character set settings: the correct character set needs to be selected when creating the database, such as utf8 or u

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.
