`
ythzjk
  • 浏览: 75462 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

理解ZEND_DB_PROFILE相关的知识

阅读更多

MYSQL的性能跟踪
mysql> help profile
Name: 'SHOW PROFILES'
Description:
Syntax:
SHOW PROFILES

SHOW PROFILE [type [, type] ... ]
    [FOR QUERY n]
    [LIMIT row_count [OFFSET offset]]

type:
    ALL
  | BLOCK IO
  | CONTEXT SWITCHES
  | CPU
  | IPC
  | MEMORY
  | PAGE FAULTS
  | SOURCE
  | SWAPS

The SHOW PROFILES and SHOW PROFILE statements display profiling
information that indicates resource usage for statements executed
during the course of the current session.

Profiling is controlled by the profiling session variable, which has a
default value of 0 (OFF). Profiling is enabled by setting profiling to
1 or ON:

mysql> SET profiling = 1;

SHOW PROFILES displays a list of the most recent statements sent to the
master. The size of the list is controlled by the
profiling_history_size session variable, which has a default value of
15. The maximum value is 100. Setting the value to 0 has the practical
effect of disabling profiling.

All statements are profiled except SHOW PROFILES and SHOW PROFILE, so
you will find neither of those statements in the profile list.
Malformed statements are profiled. For example, SHOW PROFILING is an
illegal statement, and a syntax error occurs if you try to execute it,
but it will show up in the profiling list.

SHOW PROFILE displays detailed information about a single statement.
Without the FOR QUERY n clause, the output pertains to the most
recently executed statement. If FOR QUERY n is included, SHOW PROFILE
displays information for statement n. The values of n correspond to the
Query_ID values displayed by SHOW PROFILES.

The LIMIT row_count clause may be given to limit the output to
row_count rows. If LIMIT is given, OFFSET offset may be added to begin
the output offset rows into the full set of rows.

By default, SHOW PROFILE displays Status and Duration columns. The
Status values are like the State values displayed by SHOW PROCESSLIST,
althought there might be some minor differences in interpretion for the
two statements for some status values (see
http://dev.mysql.com/doc/refman/5.1/en/thread-information.html).

Optional type values may be specified to display specific additional
types of information:

o ALL displays all information

o BLOCK IO displays counts for block input and output operations

o CONTEXT SWITCHES displays counts for voluntary and involuntary
  context switches

o CPU displays user and system CPU usage times

o IPC displays counts for messages sent and received

o MEMORY is not currently implemented

o PAGE FAULTS displays counts for major and minor page faults

o SOURCE displays the names of functions from the source code, together
  with the name and line number of the file in which the function
  occurs

o SWAPS displays swap counts

Profiling is enabled per session. When a session ends, its profiling
information is lost.

URL: http://dev.mysql.com/doc/refman/5.1/en/show-profiles.html

Examples:
mysql> SELECT @@profiling;
+-------------+
| @@profiling |
+-------------+
|           0 |
+-------------+
1 row in set (0.00 sec)

mysql> SET profiling = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TABLE T1 (id INT);
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW PROFILES;
+----------+----------+--------------------------+
| Query_ID | Duration | Query                    |
+----------+----------+--------------------------+
|        0 | 0.000088 | SET PROFILING = 1        |
|        1 | 0.000136 | DROP TABLE IF EXISTS t1  |
|        2 | 0.011947 | CREATE TABLE t1 (id INT) |
+----------+----------+--------------------------+
3 rows in set (0.00 sec)

mysql> SHOW PROFILE;
+----------------------+----------+
| Status               | Duration |
+----------------------+----------+
| checking permissions | 0.000040 |
| creating table       | 0.000056 |
| After create         | 0.011363 |
| query end            | 0.000375 |
| freeing items        | 0.000089 |
| logging slow query   | 0.000019 |
| cleaning up          | 0.000005 |
+----------------------+----------+
7 rows in set (0.00 sec)

mysql> SHOW PROFILE FOR QUERY 1;
+--------------------+----------+
| Status             | Duration |
+--------------------+----------+
| query end          | 0.000107 |
| freeing items      | 0.000008 |
| logging slow query | 0.000015 |
| cleaning up        | 0.000006 |
+--------------------+----------+
4 rows in set (0.00 sec)

mysql> SHOW PROFILE CPU FOR QUERY 2;
+----------------------+----------+----------+------------+
| Status               | Duration | CPU_user | CPU_system |
+----------------------+----------+----------+------------+
| checking permissions | 0.000040 | 0.000038 |   0.000002 |
| creating table       | 0.000056 | 0.000028 |   0.000028 |
| After create         | 0.011363 | 0.000217 |   0.001571 |
| query end            | 0.000375 | 0.000013 |   0.000028 |
| freeing items        | 0.000089 | 0.000010 |   0.000014 |
| logging slow query   | 0.000019 | 0.000009 |   0.000010 |
| cleaning up          | 0.000005 | 0.000003 |   0.000002 |
+----------------------+----------+----------+------------+
7 rows in set (0.00 sec)

mysql>

分享到:
评论

相关推荐

    Zend_Db_Adapter_Mysql 和 Zend_Db_Statement_Mysql

    不支持PDO 、MYSQLI的空间也可以用ZEND框架了 解包后到 Zend 的框架目录 library\Zend\Db 在PHP程序里 $db = Zend_Db::factory('Mysql', $params); 即把原来的 PDO_MYSQL 等改成 Mysql

    Zend_db数据库操作课件

    Zend_db数据库操作课件

    Zend_Db.pdf

    ### Zend_Db_Adapter:Zend Framework中的数据库抽象层 在深入探讨`Zend_Db_Adapter`之前,我们先简要回顾一下`Zend_Db`的作用。`Zend_Db`是Zend Framework中的一个组件,专门用于处理数据库交互。它提供了一套高级...

    Zend Framework教程之Zend_Db_Table表关联实例详解

    需要注意的是,虽然Zend_Db_Table通过定义类的方式来简化数据库操作,但在实际使用中,开发者仍需理解数据库表结构和它们之间的逻辑关系,这样才能更加有效地利用 Zend_Db_Table 提供的功能。 在实现表关联时,应当...

    yaf框架 zend_DB 简单后台实例

    在本实例中,我们将深入探讨“Yaf框架”与“Zend_DB”的集成使用,创建一个简单的后台管理系统。Yaf(Yet Another Fast Framework)是腾讯推出的一款高性能、轻量级的PHP框架,它专注于提高Web应用的运行效率。而...

    最新版的Zend_Framework 手册 中文版

    5. **对象关系映射(ORM)**:通过Zend_Db_Table和Zend_Db_Select实现,简化了数据库操作。 6. **表单处理**:Zend_Form组件提供了一种灵活的方式来创建和验证Web表单。 7. **服务端路由与控制器**:通过Zend_...

    Zend Framework教程之Zend_Db_Table用法详解

    Zend Framework是PHP开发中流行的一个开源框架,它提供了一套丰富的组件集合,其中Zend_Db_...通过以上知识点,可以深入理解Zend_Db_Table在Zend Framework中的作用及其用法,为进行高效、安全的数据库操作提供支持。

    Zend Framework入门教程之Zend_Config组件用法详解

    在本教程中,我们将深入了解Zend Framework框架中的Zend_Config...对于希望深入学习Zend Framework的开发者而言,理解和掌握Zend_Config组件是一个非常重要的步骤,它可以帮助你构建出更加模块化和易于维护的应用程序。

    Zend Framework教程之分发器Zend_Controller_Dispatcher用法详解

    主要介绍了Zend Framework教程之分发器Zend_Controller_Dispatcher用法,结合实例形式详细分析了分发器Zend_Controller_Dispatcher的结构,功能,使用技巧与相关注意事项,需要的朋友可以参考下

    Zend Framework框架教程之Zend_Db_Table_Rowset用法实例分析

    首先,需要理解Zend_Db_Table_Rowset是Zend_Db_Table_Row对象的集合。Zend_Db_Table_Row代表了数据库表中的一行数据,而Zend_Db_Table_Rowset则是这种行对象的集合。在使用时,你通常不需要直接实例化Zend_Db_Table_...

    Zend_Framework_Zh.chm

    4. **数据库操作**:掌握 `Zend_Db` 组件的使用,包括连接数据库、执行SQL语句、事务处理等,以及如何使用Active Record模式的 `Zend_Doctrine`。 5. **表单处理**:学习 `Zend_Form` 的使用,包括创建表单元素、...

    Zend Framework教程之Zend_Controller_Plugin插件用法详解

    通过以上内容,你应该对`Zend_Controller_Plugin`有了深入的理解,能够有效地利用它来扩展和定制你的Zend Framework应用程序。记住,插件是一种强大的工具,可以让你在不修改核心代码的情况下实现复杂的功能,但也要...

    Zend_Acl文档

    ### Zend_Acl 文档知识点详解 #### 一、概述 `Zend_Acl`(Access Control List)是Zend Framework中的一个组件,主要用于实现基于角色的访问控制。它通过定义角色(Role)与资源(Resource)之间的关系来管理权限...

    Zend_Framework中文手册

    Zend Framework 包含了 `Zend_Db` 和 `Zend_Doctrine`,它们提供对象关系映射功能,允许开发者以面向对象的方式处理数据库操作,减少了与SQL的直接交互。 **5. 服务导向架构(SOA)支持:** `Zend_Service` 提供...

    Zend Framework过滤器Zend_Filter用法详解

    总之,Zend Framework中的Zend_Filter组件是一个功能强大的数据处理工具,它可以让开发者通过简单的方法来确保数据的正确性和安全性,对于需要开发高效、安全的Web应用的PHP开发者而言,理解和掌握Zend_Filter组件的...

    Zend_Framework_ZH中文手册

    - **Zend_Db**:提供了一套数据库抽象层,支持多种数据库系统,简化了数据库操作。 - **Zend_Feed**:处理RSS和Atom feed,支持创建、读取和更新feed。 - **Zend_Http**:处理HTTP请求和响应,支持文件上传、Cookie...

    ZEND FRAMEWORK 1.11.7 中文参考文档

    •Zend_Db •Zend_Debug •Zend_Dojo •Zend_Dom •Zend_Exception •Zend_Feed •Zend_File •Zend_Filter •Zend_Form •Zend_Gdata •Zend_Http •Zend_InfoCard •Zend_Json •Zend_Layout •...

Global site tag (gtag.js) - Google Analytics