免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5614 | 回复: 9
打印 上一主题 下一主题

请教EXPLAIN的用法 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-15 16:26 |只看该作者 |倒序浏览
我在论坛里看到,可以使用set explain on;来查看索引使用的情况。
可是我怎么弄也没看到用的哪个索引,只有Explain set.,请大侠们帮帮忙啊。

我执行的SQL语句:
set explain on;
select * from sie_sr11_stattrunk_tgalm_hour
where metataskinstance_id=8596 and flag is null and disp is null
and time_stamp='2006-07-27';

得到的结果:
metataskinstance_+  8596
nename              CSG08
tgno                ALLCCS
lno                 268
cic
bicic
eqtyp               TRUNK
opmode              IC
ltg                 4- 7
lc                  0-16
status              RNUC & MDIU
time_stamp          2006-07-27
send_time           17:43:12
flag
disp
conclusion

Explain set.

论坛徽章:
0
2 [报告]
发表于 2006-08-15 16:45 |只看该作者
楼主 没看sqexplain.out 文件

差点没看懂,原来是dbaccess 的输出

论坛徽章:
0
3 [报告]
发表于 2006-08-15 17:11 |只看该作者
楼上的,好人做到底吧,sqexplain.out 再哪放着啊。

论坛徽章:
0
4 [报告]
发表于 2006-08-15 17:15 |只看该作者
退出dbaccess
l

论坛徽章:
0
5 [报告]
发表于 2006-08-15 17:41 |只看该作者
看到结果了,这个结果是什么意思呢?我在这个表上建有3个索引,一个是再metataskinstance_id,flag,disp,time_stamp,一个是再time_stamp,第三个先不管。我怎么区分这两个select语句分别是用的那个索引呢?

QUERY:
------
select * from sie_sr11_stattrunk_tgalm_hour
where metataskinstance_id=8596 and flag is null and disp is null
and time_stamp='2006-07-27'

Estimated Cost: 1
Estimated # of Rows Returned: 1

  1) tmn.sie_sr11_stattrunk_tgalm_hour: INDEX PATH

    (1) Index Keys: metataskinstance_id flag disp time_stamp   (Serial, fragments: ALL)
        Lower Index Filter: (((tmn.sie_sr11_stattrunk_tgalm_hour.disp IS NULL AND tmn.sie_sr11_stattrunk_tgalm_hour.flag IS NULL ) AND tmn.sie_sr11_stattrunk_tgalm_hour.time_stamp = datetime(2006-07-27) year to day ) AND tmn.sie_sr11_stattrunk_tgalm_hour.metataskinstance_id = 8596 )



QUERY:
------
select * from sie_sr11_stattrunk_tgalm_hour
where
time_stamp='2006-07-27'

Estimated Cost: 1
Estimated # of Rows Returned: 1

  1) tmn.sie_sr11_stattrunk_tgalm_hour: SEQUENTIAL SCAN

        Filters: tmn.sie_sr11_stattrunk_tgalm_hour.time_stamp = datetime(2006-07-27) year to day

论坛徽章:
0
6 [报告]
发表于 2006-08-16 21:03 |只看该作者
大侠们,帮帮忙,给看看吧

论坛徽章:
0
7 [报告]
发表于 2006-08-16 21:46 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
8 [报告]
发表于 2006-08-18 13:07 |只看该作者
大家帮忙看看吧,都好几天了

论坛徽章:
0
9 [报告]
发表于 2006-08-18 23:15 |只看该作者

回复 5楼 liumangya 的帖子

For query 1:
index, index key used "metataskinstance_id flag disp time_stamp"
For query 2:
no index being used, sequential scan

I am wondering how many records in the table, how the data distribution it is on the time_stamp field.  If you are using IDS 7.3 or later, you can use SQL Optimizer Directive to force using index scan, even point out which index you are going to use.

论坛徽章:
0
10 [报告]
发表于 2006-08-18 23:20 |只看该作者

回复 9楼 IFMXDBA 的帖子

moreover, try update statistics then run it with set explain on, see if there is any changes.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP