`
myreligion
  • 浏览: 205136 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

The Mysql tool I’ve been waiting for years. zt

阅读更多

I've just been pointed to the nice tool which I was waiting for years to see. It is fincore - little perl script which allows you to see what pages of file are cached in OS memory. This is really cool.


When it comes to MySQL it is very useful with MyISAM tables which has their data file cached by OS cache only so you do not have any good information from MySQL side on what data is cached. You can also use it with Innodb to see how much memory are you wasting with double buffering by not using of O_DIRECT.

Besides general clues such as 50% of my file is cached you should watch for dynamics - for example check it during backup process and compare it due to normal load - this can give you a clue if slow down happens because of extra IO pressure or just because pages were washed out. You can also check how pages are cached. For example every second page cached may be helpful for point queries but does not save a lot of IO for doing table scans.

One thing I'm still missing is looking it from another side - so I have say 10GB of OS cache used on the server but how can I tell what is using it ? This look from another side would help me dramatically to find out what is causing cache pressure and what needs to be worked on. Scanning all files on filesystem and checking which are cached obviously does not work.

The fincore looks more like proof of concept tool - it is a bit simplistic, however being written in Perl it is easily hackable - if you want to make it to print percentage of file cached or "graph" showing how cached pages are distributed among file is very easy.

The great thing about this tool it is very fast and it does not disturbs OS file cache by using mincore function to get pages which are currently in cache.

This function is actually the real meat here - the tool is simplistic but it shows how to use the function so you can write real stuff. For example using this tool MySQL can easily add amount of cached data per table for MyISAM and Archive tables to INFORMATION_SCHEMA (or other system tables) which would be really cool Of course than one would need to implement cache content tracking for storage engines which cache everything in their own cache memory - Innodb, Falcon, Maria.

Having information about how large portion of table is cached would allow optimizer to take much smarter decisions in many cases.

Lets now see some examples:

引用
PLAIN TEXTSQL:
[root@DB01 mysql]# du -h ib_log*
257M    ib_logfile0
257M    ib_logfile1
[root@DB01 mysql]# perl /tmp/fincore --justsummarize ib_logfile0 ib_logfile1
page size: 4096 bytes
24141 pages, 94.3 Mbytes IN core FOR 2 files; 12070.50 pages, 47.2 Mbytes per file.
[root@DB01 mysql]# perl /tmp/fincore --justsummarize ib_logfile0
page size: 4096 bytes
1 page, 4.0 kbytes IN core FOR 1 file; 1.00 page, 4.0 kbytes per file.
[root@DB01 mysql]# perl /tmp/fincore --justsummarize ib_logfile1
page size: 4096 bytes
24169 pages, 94.4 Mbytes IN core FOR 1 file; 24169.00 pages, 94.4 Mbytes per file.


So we can see one of Innodb log files is practically uncached while other has about 1/3rd cached - this makes sense, perhaps second log file is being written now and there is a "tail" of pages which just were not removed from the cache yet. As Innodb does not read logfile unless in recovery these are waste and Innodb could use fadvice to give instruction to kernel not to cache these as long as it can't perform direct IO to log files on Linux because it is not aligned.

引用
PLAIN TEXTSQL:
[root@DB01 mysql]# du -h ibdata*
246G    ibdata1
[root@DB01 mysql]# perl /tmp/fincore --justsummarize ibdata1
page size: 4096 bytes
0 pages, 0.0  bytes IN core FOR 1 file; 0.00 pages, 0.0  bytes per file.


Out of 250GB innodb data file none of pages are in cache - this is because this instance is using O_DIRECT flag to bypass data buffering and we can well see it works.

Lets now see stats for MyISAM tables:

引用
PLAIN TEXTSQL:
[root@DB01 logs]# du -h performance_log_080318.MYD
1.1G    performance_log_080318.MYD
[root@DB01 logs]# perl /tmp/fincore --justsummarize performance_log_080318.MYD
page size: 4096 bytes
497 pages, 1.9 Mbytes IN core FOR 1 file; 497.00 pages, 1.9 Mbytes per file.

[root@DB01 logs]# du -h performance_log_080319.MYD
229M    performance_log_080319.MYD
[root@DB01 logs]# perl /tmp/fincore --justsummarize performance_log_080319.MYD
page size: 4096 bytes
28415 pages, 111.0 Mbytes IN core FOR 1 file; 28415.00 pages, 111.0 Mbytes per file.
[root@DB01 logs]#


The performance log for yesterday is almost out of cache. It is about 0:50 by server clock this is why we still can see some pages remaining. Today log file is 50% in cache. Knowing access pattern to the file you can draw some conclusions about how much IO pressure we have on this server.

P.S If you would hack this tool or know any similar tools please let me know.


分享到:
评论

相关推荐

    Connector_J [MySQL ConnectorJ is the official JDBC driver for MySQL.].rar

    Connector_J [MySQL ConnectorJ is the official JDBC driver for MySQL.].rar,包括: mysql-connector-java-5.1.22.tar.gz mysql-connector-java-5.1.22.zip

    MySql.Data.dll 6.4.4 for .net 4.0

    MySql.Data.dll 6.4.4 for .net 4.0

    dbForge.Studio.for.MySQL.v.5.0.50.0.Professional破解版

    dbForge Studio for MySQL 5.0.50 Professional 破解版本 软件类别:国外软件/数据库类 软件授权:共享版 运行环境:Winxp/vista/win7/2000/2003 更新时间:2011-12-7 15:32:48 出 品 人:官方网站 | 专区 ...

    mysql-connector-java-5.1.40.tar.gz

    在这个例子中,`Class.forName("com.mysql.jdbc.Driver")` 加载了MySQL的JDBC驱动,然后`DriverManager.getConnection()` 创建了一个数据库连接。 MySQL Connector/J 5.1.40 版本支持JDBC 4.0规范,适用于Java SE 6...

    最新mysql.data.dll(6.7.4.0) for .net4.5

    这个dll是直接从mysql官网下的(http://dev.mysql.com/downloads/windows/visualstudio/).支持.net 4.5。如果大家没有oracle账号,可以在这里下载

    mysql tool

    6. **性能监控**:为了优化数据库性能,MySQL Tool可能提供性能监视工具,显示数据库的运行状态,包括查询执行时间、内存使用、磁盘I/O等关键指标。 7. **许可证信息**:"gpl.txt"文件可能是开源软件的GPL许可证...

    mysql 异常com.mysql.jdbc.CommunicationsException

    本次异常的具体描述为:“Communications link failure due to underlying exception: **BEGINNESTED EXCEPTION** java.io.EOFException STACK TRACE: java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully...

    My5.6版本:MySQL-5.6.22-1.el6.i686.rpm-bundle.tar

    MySQL-5.6.22-1.el6.i686.rpm-bundle.tar,关注我可以下载更多的资源,私信我,我会把你需要的资源发送给你

    mysql-connector-java-8.0.31-jar包

    MySQL Connector/J是MySQL数据库与Java应用程序之间的桥梁,它是一个实现了JDBC(Java Database Connectivity)标准的驱动程序,允许Java开发者在Java应用中访问和操作MySQL数据库。本资源提供的"mysql-connector-...

    mysql-connector-java-8.0.21.jar

    For license and attribution notices for these materials, please refer to the LICENSE file. For more information on MySQL Connector/J, visit https://dev.mysql.com/doc/connector-j/8.0/en/ For ...

    mysql安装失败

    win7 系统 the security settings could not be applied to the database 在安装mysql的时候,就会遇到以下错误。遇到错误不可怕,怕的就是被错误所击倒! The security settings could not be applied to the ...

    Debugger.for.MySQL破解版

    在mysql中调试存储过程的好工具,好的地方就是它可以打断点,单步执行

    Toad for MySQL_Freeware V8.0 免费版 .exe

    Toad for MySQL_Freeware_8.0.0.296 免费版 实用工具

    C#连接mysql的Mysql.data.dll 5.0.8.1和6.2.1.0

    为了实现C#与MySQL之间的通信,开发人员需要依赖特定的驱动程序,这就是Mysql.data.dll的角色。本篇文章将详细探讨如何使用C#连接MySQL数据库,特别是针对Mysql.data.dll版本5.0.8.1和6.2.1.0。 首先,`Mysql.data....

    MySQL High Availability 2nd 原版pdf by Bell

    The authors of this book have been creating parts of MySQL and working with it for many years. Dr. Charles Bell is a senior developer leading the MySQL Utilities team. He has also worked on ...

    MySQL出现Waiting for table metadata lock的原因方法

    MySQL在进行alter table等DDL操作时,有时会出现Waiting for table metadata lock的等待场景。而且,一旦alter table TableA的操作停滞在Waiting for table metadata lock的状态,后续对TableA的任何操作(包括读)...

    Devart dbForge Studio for MySQL Professional Edition v7.1.13

    The Best MySQL GUI Tool You Can Find dbForge Studio for MySQL is a universal GUI for managing, developing and administrating MySQL and MariaDB databases. The tool allows to create and execute queries,...

    MySQL 5.6 Reference Manual

    1. Licenses for Third-Party Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    mysql-connector-java-5.1.22.tar.gz

    Class.forName("com.mysql.jdbc.Driver"); return DriverManager.getConnection(url, username, password); } catch (ClassNotFoundException | SQLException e) { e.printStackTrace(); } return null; } }...

    MySql.Data.dll For C#

    MySQL.Data.dll 是一个重要的.NET框架库,专门为C#开发者提供与MySQL数据库交互的功能。这个库使得在C#环境中,开发者可以像操作SQL Server那样方便地操作MySQL数据库,大大简化了跨平台数据库应用的开发工作。 ...

Global site tag (gtag.js) - Google Analytics