- mysql8中测试
- 查看profiling 是否开启
| select @@profiling; |
| |
| show variables like 'profiling'; |
- profiling=0 代表关闭,我们需要把 profiling 打开,即设置为 1:
| MariaDB [jdbc]> select * from t_account; |
| +----+----------+-------+ |
| | id | username | money | |
| +----+----------+-------+ |
| | 1 | goudan | 900 | |
| | 2 | gousheng | 1100 | |
| +----+----------+-------+ |
| 2 rows in set (0.000 sec) |
| MariaDB [jdbc]> show profiles; |
| + |
| | Query_ID | Duration | Query | |
| + |
| | 1 | 0.00133903 | show variables like 'profiling' | |
| | 2 | 0.00015757 | select @@profiling | |
| | 3 | 0.00007482 | select * from t_account | |
| | 4 | 0.00007830 | select * from t_account | |
| | 5 | 0.00006953 | select * from t_account | |
| | 6 | 0.00006093 | select * from t_account | |
| | 7 | 0.00006677 | select * from t_account | |
| | 8 | 0.00007320 | select * from t_account | |
| | 9 | 0.00007997 | select * from t_account | |
| | 10 | 0.00007702 | select * from t_account | |
| | 11 | 0.00006816 | select * from t_account | |
| + |
| 11 rows in set (0.000 sec) |
| |
| MariaDB [jdbc]> show profile; |
| + |
| | Status | Duration | |
| + |
| | Starting | 0.000025 | |
| | Waiting for query cache lock | 0.000004 | |
| | Init | 0.000003 | |
| | Checking query cache for query | 0.000007 | |
| | Checking privileges on cached | 0.000004 | |
| | Checking permissions | 0.000008 | |
| | Sending cached result to clien | 0.000010 | |
| | Updating status | 0.000004 | |
| | Reset for next command | 0.000003 | |
| + |
| 9 rows in set (0.002 sec) |

| MariaDB [jdbc]> show profile for query 7; |
| + |
| | Status | Duration | |
| + |
| | Starting | 0.000026 | |
| | Waiting for query cache lock | 0.000004 | |
| | Init | 0.000003 | |
| | Checking query cache for query | 0.000006 | |
| | Checking privileges on cached | 0.000003 | |
| | Checking permissions | 0.000008 | |
| | Sending cached result to clien | 0.000010 | |
| | Updating status | 0.000004 | |
| | Reset for next command | 0.000003 | |
| + |
| 9 rows in set (0.000 sec) |
| MariaDB [jdbc]> show profile cpu,block io for query 6; |
| + |
| | Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out | |
| + |
| | Starting | 0.000023 | 0.000010 | 0.000012 | 0 | 0 | |
| | Waiting for query cache lock | 0.000003 | 0.000001 | 0.000002 | 0 | 0 | |
| | Init | 0.000002 | 0.000001 | 0.000001 | 0 | 0 | |
| | Checking query cache for query | 0.000005 | 0.000002 | 0.000003 | 0 | 0 | |
| | Checking privileges on cached | 0.000003 | 0.000001 | 0.000002 | 0 | 0 | |
| | Checking permissions | 0.000006 | 0.000003 | 0.000003 | 0 | 0 | |
| | Sending cached result to clien | 0.000012 | 0.000005 | 0.000007 | 0 | 0 | |
| | Updating status | 0.000004 | 0.000002 | 0.000002 | 0 | 0 | |
| | Reset for next command | 0.000003 | 0.000001 | 0.000002 | 0 | 0 | |
| + |
| 9 rows in set (0.000 sec) |
| # 在 /etc/my.cnf 中新增一行:开启查询缓存 |
| query_cache_type=1 |
| |
| # 重启 |
| systemctl restart mysqld |
| |
| # 开启profiling |
| set profiling=1; |
| |
| # 任意执行1条查询语句 |
| select * from locations; |
| |
| # 查看 |
| show profile for query 1; |
- sql语法顺序

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
2021-06-08 maven入门