• nformix调优之执行计划取得


    首先编辑q.sql如下

    set explain on;
    set explain off;
    set explain on avoid_execute;
    set explain file  to "/tmp/temp.out";
    select count(*)  from systables;
    select first 1 date(current) from systables #此处换成任意需要调整的sql

    登陆informix服务器,执行dbaccess dbname a.sql结果如下

    Database selected.
    Explain set.
    Explain set.
    Explain set.
    Explain set.
          (count(*)) 
                1142
    1 row(s) retrieved.
    (expression) 
    11/20/2012
    1 row(s) retrieved.
    Database closed.

    查看详细任务计划 more /tmp/temp.out如下

    UERY: (OPTIMIZATION TIMESTAMP: 11-20-2012 15:04:13)
    ------
    select count(*)  from tfa_alarm_relation
    Estimated Cost: 1
    Estimated # of Rows Returned: 1
      1) informix.tfa_alarm_relation: INDEX PATH
        (1) Index Name: (count)
            Index Keys: (count)
    Query statistics:
    -----------------
      Table map :
      ----------------------------
      Internal name     Table name
      ----------------------------
      type     rows_prod  est_rows  rows_cons  time
      -------------------------------------------------
      group    1          1         0          00:00.00
    QUERY: (OPTIMIZATION TIMESTAMP: 11-20-2012 15:04:13)
    ------
    select first 1 date(current) from systables
    Estimated Cost: 78
    Estimated # of Rows Returned: 1142
      1) informix.systables: SEQUENTIAL SCAN
    Query statistics:
    -----------------
      Table map :
      ----------------------------
      Internal name     Table name
      ----------------------------
      t1                systables
      type     table  rows_prod  est_rows  rows_scan  time       est_cost
      -------------------------------------------------------------------
      scan     t1     1          1142      3          00:00.00   78      
    QUERY: (OPTIMIZATION TIMESTAMP: 11-20-2012 15:06:55)
    ------
    select count(*)  from systables
    Estimated Cost: 1
    Estimated # of Rows Returned: 1
      1) informix.systables: INDEX PATH

    根据任务计划可以看出sql在哪一个环境耗时过长,进而对其进行优化。 

    下一节找一个这样的sql进行针对性练习

  • 相关阅读:
    laravel路由和MVC
    laravel目录介绍
    laravel下载安装
    Mac 程序员的十种武器
    Python中列表的copy方法
    Ubuntu 安装vim失败解决
    Linux userAdd 增加用户如果没有配置文件情况解决
    Ubuntu 软件管理
    awk工具详解
    httpsClient
  • 原文地址:https://www.cnblogs.com/vigarbuaa/p/2778192.html
Copyright © 2020-2023  润新知