mysql调优(一)--性能监控

一、mysql的基础架构

  • 思维导图
    在这里插入图片描述

  • 架构图
    在这里插入图片描述

一、性能监控

1.使用show profile查询剖析工具,可以指定具体的type

此工具默认是禁用的,可以通过服务器变量在绘画级别动态的修改

1.1 类型
  • 连接MYSQL

格式: mysql -h 主机地址 -u 用户名 -p 用户密码

  • 查询数据库

show databases;

  • 使用数据库

use 数据库名称

  • 查询表

show tables;

  • 查看是否支持这个功能(查询为yes表示支持):

show variables like ‘have_profiling’;
±---------------±------+
| Variable_name | Value |
±---------------±------+
| have_profiling | NO |
±---------------±------+

  • 此工具默认是禁用的,可以通过服务器变量在绘画级别动态的修改,1为开启

set profiling=1;

  • 当设置完成之后,在服务器上执行的所有语句,都会测量其耗费的时间和其他一些查询执行状态变更相关的数据。

select * from emp;

  • 在mysql的命令行模式下只能显示两位小数的时间,可以使用如下命令查看具体的执行时间

show profiles;

  • 执行如下命令可以查看详细的每个步骤的时间,n为query_id,上一个命令可以查看。

show profile for query n;

  • 其他详情查看,尾部加\G可以系统列出属性

在这里插入图片描述

2.使用performance schema来更加容易的监控mysql

2.1概念

MySQL的performance schema 用于监控MySQL server在一个较低级别的运行过程中的资源消耗、资源等待等情况。

2.2.特点
  • 1、提供了一种在数据库运行时实时检查server的内部执行情况的方法。performance_schema 数据库中的表使用performance_schema存储引擎。该数据库主要关注数据库运行过程中的性能相关的数据,与information_schema不同,information_schema主要关注server运行过程中的元数据信息。
  • 2、performance_schema通过监视server的事件来实现监视server内部运行情况, “事件”就是server内部活动中所做的任何事情以及对应的时间消耗,利用这些信息来判断server中的相关资源消耗在了哪里?一般来说,事件可以是函数调用、操作系统的等待、SQL语句执行的阶段(如sql语句执行过程中的parsing 或 sorting阶段)或者整个SQL语句与SQL语句集合。事件的采集可以方便的提供server中的相关存储引擎对磁盘文件、表I/O、表锁等资源的同步调用信息。
  • 3、performance_schema中的事件与写入二进制日志中的事件(描述数据修改的events)、事件计划调度程序(这是一种存储程序)的事件不同。performance_schema中的事件记录的是server执行某些活动对某些资源的消耗、耗时、这些活动执行的次数等情况。
  • 4、performance_schema中的事件只记录在本地server的performance_schema中,其下的这些表中数据发生变化时不会被写入binlog中,也不会通过复制机制被复制到其他server中。
  • 5、当前活跃事件、历史事件和事件摘要相关的表中记录的信息。能提供某个事件的执行次数、使用时长。进而可用于分析某个特定线程、特定对象(如mutex或file)相关联的活动。
  • 6、PERFORMANCE_SCHEMA存储引擎使用server源代码中的“检测点”来实现事件数据的收集。对于performance_schema实现机制本身的代码没有相关的单独线程来检测,这与其他功能(如复制或事件计划程序)不同。
  • 7、收集的事件数据存储在performance_schema数据库的表中。这些表可以使用SELECT语句查询,也可以使用SQL语句更新performance_schema数据库中的表记录(如动态修改performance_schema的setup_*开头的几个配置表,但要注意:配置表的更改会立即生效,这会影响数据收集)。
  • 8、performance_schema的表中的数据不会持久化存储在磁盘中,而是保存在内存中,一旦服务器重启,这些数据会丢失(包括配置表在内的整个performance_schema下的所有数据)。
  • 9、MySQL支持的所有平台中事件监控功能都可用,但不同平台中用于统计事件时间开销的计时器类型可能会有所差异。
2.3.performance schema入门

在mysql的5.7版本中,性能模式是默认开启的,如果想要显式的关闭的话需要修改配置文件,不能直接进行修改,会报错Variable ‘performance_schema’ is a read only variable。

  • 查看performance_schema的属性

SHOW VARIABLES LIKE ‘performance_schema’;
±-------------------±----------------+
| Variable_name | Value |
±-------------------±---------------+
| performance_schema

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Preface..................................................................................................................................9 Organization of This Book........................................................................................9 Conventions Used in This Book..............................................................................9 How to Contact Us....................................................................................................10 Acknowledgments.....................................................................................................11 Chapter 1. Introduction.....................................................................................................13 1.1 What Is the Microsoft .NET Framework?..................................................13 1.2 What Is Visual Basic .NET?............................................................................14 1.3 An Example Visual Basic .NET Program...................................................14 Chapter 2. The Visual Basic .NET Language...............................................................23 2.1 Source Files.........................................................................................................23 2.2 Identifiers.............................................................................................................23 2.3 Keywords..............................................................................................................24 2.4 Literals...................................................................................................................27 2.5 Types......................................................................................................................31 2.6 Namespaces........................................................................................................40 2.7 Symbolic Constants..........................................................................................42 2.8 Variables...............................................................................................................43 2.9 Scope......................................................................................................................44 2.10 Access Modifiers..............................................................................................44 2.11 Assignment........................................................................................................45 2.12 Operators and Expressions.........................................................................46 2.13 Statements........................................................................................................52 2.14 Classes................................................................................................................60 2.15 Interfaces...........................................................................................................85 2.16 Structures..........................................................................................................88 2.17 Enumerations...................................................................................................91 2.18 Exceptions..........................................................................................................93 2.19 Delegates...........................................................................................................98 2.20 Events................................................................................................................101 2.21 Standard Modules.........................................................................................104 2.22 Attributes.........................................................................................................104 2.23 Conditional Compilation.............................................................................108 2.24 Summary..........................................................................................................109 Chapter 3. The .NET Framework..................................................................................111 3.1 Common Language Infrastructure (CLI) and Common Language Runtime (CLR)..........................................................................................................111 3.2 Common Type System (CTS).....................................................................111 3.3 Portions of the CLI..........................................................................................112 3.4 Modules and Assemblies...............................................................................113 3.5 Application Domains.......................................................................................116 3.6 Common Language Specification (CLS).................................................116 3.7 Intermediate Language (IL) and Just-In-Time (JIT) Compilation117 3.8 Metadata.............................................................................................................117 3.9 Memory Management and Garbage Collection....................................118 3.10 A Brief Tour of the .NET Framework Namespaces...........................122 Programming Visual Basic .NET 3 3.11 Configuration...................................................................................................125 3.12 Summary..........................................................................................................131 Chapter 4. Windows Forms I: Developing Desktop Applications.............................133 4.1 Creating a Form................................................................................................133 4.2 Handling Form Events....................................................................................143 4.3 Relationships Between Forms.....................................................................145 4.4 MDI Applications...............................................................................................147 4.5 Component Attributes....................................................................................155 4.6 2-D Graphics Programming with GDI+...................................................160 4.7 Printing.................................................................................................................174 4.8 Summary.............................................................................................................186 Chapter 5. Windows Forms II: Controls, Common Dialog Boxes, and Menus......187 5.1 Common Controls and Components.........................................................187 5.2 Control Events...................................................................................................204 5.3 Form and Control Layout..............................................................................204 5.4 Common Dialog Boxes...................................................................................210 5.5 Menus...................................................................................................................215 5.6 Creating a Control...........................................................................................227 5.7 Summary.............................................................................................................236 Chapter 6. ASP.NET and Web Forms: Developing Browser-Based Applications237 6.1 Creating a Web Form.....................................................................................238 6.2 Handling Page Events.....................................................................................251 6.3 More About Server Controls........................................................................253 6.4 Adding Validation.............................................................................................268 6.5 Using Directives to Modify Web Page Compilation.............................283 6.6 ASP.NET Objects: Interacting with the Framework...........................291 6.7 Discovering Browser Capabilities...............................................................296 6.8 Maintaining State.............................................................................................298 6.9 Application-Level Code and global.asax.................................................304 6.10 Web-Application Security...........................................................................307 6.11 Designing Custom Controls.......................................................................320 6.12 Summary..........................................................................................................328 Chapter 7. Web Services................................................................................................329 7.1 Creating a Web Service.................................................................................329 7.2 Testing a Web Service with a Browser....................................................333 7.3 Web-Service Descriptions.............................................................................335 7.4 Consuming a Web Service............................................................................335 7.5 Web-Service Discovery..................................................................................340 7.6 Limitations of Web Services........................................................................340 7.7 Summary.............................................................................................................341 Chapter 8. ADO.NET: Developing Database Applications.......................................343 8.1 A Brief History of Universal Data Access................................................343 8.2 Managed Providers..........................................................................................343 8.3 Connecting to a SQL Server Database....................................................344 SQL Server Authentication.............................................................................................347 8.4 Connecting to an OLE DB Data Source...................................................348 8.5 Reading Data into a DataSet.......................................................................349 4 8.6 Relations Between DataTables in a DataSet........................................360 8.7 The DataSet's XML Capabilities.................................................................362 8.8 Binding a DataSet to a Windows Forms DataGrid..............................364 8.9 Binding a DataSet to a Web Forms DataGrid.......................................367 8.10 Typed DataSets.............................................................................................368 8.11 Reading Data Using a DataReader.........................................................370 8.12 Executing Stored ProceduresThrough a SqlCommand Object....371 8.13 Summary..........................................................................................................374 Appendix A. Custom Attributes Defined in the System Namespace......................375 Appendix B. Exceptions Defined in the System Namespace...................................381 Appendix D. Resources for Developers......................................................................391 D.1 .NET Information.............................................................................................391 D.2 Discussion Lists................................................................................................392 Netiquette.........................................................................................................................392 Appendix E. Math Functions..........................................................................................395 Colophon...........................................................................................................................398

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值