1. 客户端向服务器发送 sql
2. 服务器解析 sql
3. 服务器创建执行计划
4. 服务器执行 sql
5. 客户端接收 sql 执行结果
1. linux 命令 (步骤 1-5)
$ time psql -c 'select count(*) pg_class'
real 0m0.018s
user 0m0.001s
sys 0m0.001s
2. \timing (步骤 1-5)
=# \timing
Timing is on.
=# \timing
Timing is off.
3. 输出 LOG (步骤 2-4)
设置 postgresql.conf 的 log_min_duration_statement
4. EXPLAIN ANALYZE SELECT ... (步骤 4)
5. pg_stat_statements 模块 (步骤 4)
PostgreSQL 8.4 以后 contrib 模块
=# SELECT query, calls, total_time, rows, total_time/calls AS once_time FROM pg_stat_statements ORDER BY once_time DESC LIMIT 3;
2. 服务器解析 sql
3. 服务器创建执行计划
4. 服务器执行 sql
5. 客户端接收 sql 执行结果
1. linux 命令 (步骤 1-5)
$ time psql -c 'select count(*) pg_class'
real 0m0.018s
user 0m0.001s
sys 0m0.001s
2. \timing (步骤 1-5)
=# \timing
Timing is on.
=# \timing
Timing is off.
3. 输出 LOG (步骤 2-4)
设置 postgresql.conf 的 log_min_duration_statement
4. EXPLAIN ANALYZE SELECT ... (步骤 4)
5. pg_stat_statements 模块 (步骤 4)
PostgreSQL 8.4 以后 contrib 模块
=# SELECT query, calls, total_time, rows, total_time/calls AS once_time FROM pg_stat_statements ORDER BY once_time DESC LIMIT 3;
0 件のコメント:
コメントを投稿