GBase 8s 使用sqltrace跟踪sql性能

SQLTrace用于跟踪执行sql的性能,可用于定位性能较差的sql,从而进行优化。

Example
打开sqltrace跟踪15000条sql,所需内存:15000*4k=60MB

dbaccess sysadmin - <<!
EXECUTE FUNCTION task("set sql tracing on","15000","4","high","global");
!

查看执行耗时较长sql:

dbaccess sysmaster -<<!
unload to sql.unl 
select sql_maxtime,sql_avgtime,sql_statement 
from syssqltrace order by sql_maxtime desc;
!

查看当前路径下生成的sql.unl文件

查询跟踪信息,根据需要排序

dbaccess sysmaster - <<!
select * from syssqltrace;
!

命令查看trace信息:

onstat -g his

关闭sqltrace

dbaccess sysadmin - <<!
EXECUTE FUNCTION task("set sql tracing off");
!

标签: sqltrace

添加新评论