1.查看profiling

mysql之show profiles介绍

 

2.开启profiling
mysql之show profiles介绍

 

3.查看使用过的sql

mysql之show profiles介绍

 

4.查看query_id = 2 的情况
mysql之show profiles介绍
 
 若出现以下4种说明sql写的有问题,需要优化

converting HEAP to MyISAM 查询结果太大,内存都不够用了,往磁盘上搬了

Creating tmp table 创建临时表(拷贝数据到临时表,用完在删除)

Copying to tmp table on disk 把内存中临时表复制到磁盘

locked 锁定

 

show profile 的格式如下:

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

相关文章: