大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> 数据库 -> 使用DB2look 重新创建优化器访问计划(4)

使用DB2look 重新创建优化器访问计划(4)

时间: 2021-07-31 作者:daque

天生 db2exfmt 输入:  db2exfmt -d dummydb -g tic -w -1 -n % -s % -# 0 -o test_dummydb_exfmt.txt  查看 test_dummydb_exfmt.txt 的实质并察看考察安置:  access plan:  -----------   total cost:   25.8843   query degree:  1                rows                return                (   1)                 cost                  i/o                  |                  4                msjoin               (   2)                25.8843                   2             /-----+-----\          1                4        tbscan           tbscan        (   3)           (   5)        12.913           12.9682           1                1          |                |          8               35    table: skapoor   table: skapoor           org             staff   您在尝试中赢得了一个各别于消费中的考察安置。本例中,明显咱们在尝试体例上仍旧将 dft_queryopt(默许的查问优化)从 5 窜改为 3。所以,您看到的是 merge join 安置,而非 hash join 安置,以及有一点点辨别的总本钱(total cost)。  由于那些安置不配合(假如您不决定干什么),以是要查看 db2exfmt 输入中的摆设。见 表 2。  正如您不妨看到的,尝试(test)和消费(production)之间的专一辨别即是优化级别(optimization level),咱们刻意将之从 5 窜改为 3,不过为了表露在尝试情况中复制消费考察安置何以会不可功。  本例中,您将运用下列 update 语句将 dft_queryopt 革新为 5:  update db cfg for sample using dft_queryopt 5  而后,遏止并从新贯穿数据库。再次对 dummydb 发出 query.sql,并运用 db2exfmt 吩咐天生考察安置。这次,您将看到沟通的考察安置。要不,就进一步保证正文中所计划的一切优化器关系的参数都是沟通的。  示例 2:  该示例表露了 db2look 吩咐中 -m 选项的要害性。前方用 -m 选项搜集的统计数据在尝试和消费中该当沟通。本例中,咱们将看到没有精确革新统计数据时安置是怎样变革的。   数据库处置器摆设、数据库摆设和 db2set 备案表变量与上头 示例 1 中的沟通。这边的形式名是 skapoor。用您的表的形式替代它。数据库是沟通的,与 示例 1 中一律是 sample 和 dummy。这边所运用的平台和 db2level 是 aix 5.1 和 db2 udb ese v8.2,fix pack 8,单分区。  在 sample 数据库上实行下列吩咐:  db2 "connect to sample"  db2 "create index name_ind on staff (name,id)"  db2 "runstats on table skapoor.staff with distribution and indexes all"  db2 "set current explain mode explain"  db2 "select name from staff where id=10 order by name"  db2 "set current explain mode no"  db2 "terminate"  运用 db2exfmt 天生考察安置。您将看到底下的考察安置:   access plan:  -----------          total cost:             0.111065          query degree:           1        rows       return       (   1)        cost         i/o         |          1       ixscan       (   2)      0.111065          0         |         35   index: skapoor      name_ind  从 sample 数据库中搜集 db2look 消息:  db2look -d sample -l -o storage.out  db2look -d sample -e -a -m -t staff -o db2look.out  db2look -d sample -f -fd -o config.out  窜改那些文献以使您贯穿 dummy 数据库,而非之前在上头 示例 1 中所贯穿的 sample 数据库。   细工窜改统计数据之一。在 db2look.out 文献中探求下列语句(请提防,形式名、tabschema 和 indschema 大概与您的简直情景各别):  update sysstat.indexes  set nleaf=1,      nlevels=1,      firstkeycard=35,      first2keycard=35,      first3keycard=-1,      first4keycard=-1,      fullkeycard=35,      clusterfactor=-1.000000,      clusterratio=100,      sequential_pages=0,      density=0,      average_sequence_gap=0.000000,      average_sequence_fetch_gap=0.000000,      average_sequence_pages=0.000000,      average_sequence_fetch_pages=0.000000,      average_random_pages=1.000000,      average_random_fetch_pages=0.000000,      numrids=35,      numrids_deleted=0,      num_empty_leafs=0  where indname = ’name_ind’ and indschema = ’skapoor ’        and tabname = ’staff’ and tabschema = ’skapoor ’;  此刻,将 firstkeycard、first2keycard、fullkeycard 和 numrids 从 35 窜改为 37。此刻生存 db2look.out 文献并运转这 3 个文献:  db2 -tvf config.out > config_output.out  db2 -tvf storage.out > storage_output.out  db2 terminate  db2stop  db2start  db2 -tvf db2look.out > db2look_output.out  查看前两个文献 config_output.out 和 storage_output.out 的实质,以保证它们运转胜利。此刻,查看 db2look_output.out 文献的实质。您将看到下列革新语句波折了:  update sysstat.indexes set nleaf=1, nlevels=1, firstkeycard=37, first2keycard=37  , first3keycard=-1, first4keycard=-1, fullkeycard=37, clusterfactor=-1.000000, c  lusterratio=100, sequential_pages=0, density=0, average_sequence_gap=0.000000, a  verage_sequence_fetch_gap=0.000000, average_sequence_pages=0.000000, average_seq  uence_fetch_pages=0.000000, average_random_pages=1.000000, average_random_fetch_  pages=0.000000, numrids=37, numrids_deleted=0, num_empty_leafs=0 where indname =   ’name_ind’ and indschema = ’skapoor ’ and tabname = ’staff’ and tabschema = ’sk  apoor ’  db21034e  the command was processed as an sql statement because it was not a  valid command line processor command.  during sql processing it returned:  sql1227n  the catalog statistic "37" for column "fullkeycard" is out of range  for its target column, has an invalid format, or is inconsistent in relation  to some other statistic. reason code = "8".  sqlstate=23521  正如您不妨看到的,上头用来索引 name_ind 的 update 语句波折了,由于 fullkeycard 大于表的基数(card)。正如经过 db2look.out 文献中的下列革新语句不妨看到的,card 是 35:  update sysstat.tables  set card=35,      npages=1,      fpages=1,      overflow=0,      active_blocks=0  where tabname = ’staff’ and tabschema = ’skapoor ’;  此刻,再次以证明形式运转沟通的查问:  db2 "select name from staff where id=10 order by name"  并天生考察安置。您将看到它是各别的:  access plan:  -----------          total cost:             12.972          query degree:           1        rows       return       (   1)        cost         i/o         |          1       tbscan       (   2)       12.972          1         |          1       sort       (   3)       12.9708          1         |          1       tbscan       (   4)       12.9682          1         |         35   table: skapoor        staff  该示例表露,即使在表上爆发 write 震动时运转 runstats,统计数据就大概与本示例中的不普遍。所以,用来革新统计数据的 update 语句大概波折并爆发 sql1227n 缺点动静。一切的 update 语句都运转胜利格外要害,即使生存不普遍性,就该当举行补缀并从新运转。本例中,处置计划是将 keycards 和 numrids 从 37 从新窜改为 35。 

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.