软件开发数据库

关于执行计划

获得执行计划后能够看到表之间的关联关系。截取部分信息如下所示: type     table  rows_prod  est_rows  rows_scan  time       est_cost  ------------------------------...显示全部

获得执行计划后能够看到表之间的关联关系。

截取部分信息如下所示:

type     table  rows_prod  est_rows  rows_scan  time       est_cost

  -------------------------------------------------------------------

  scan     t4     359712959  1799989120  359712959  2432:33.37   2      

  type     rows_prod  est_rows  time       est_cost

  -------------------------------------------------

  nljoin   359712959  4693364   2435:09.61   2753412

  type     table  rows_prod  est_rows  rows_scan  time       est_cost

  -------------------------------------------------------------------

  scan     t5     54564896   68238136  54564896   1183:09.90   1      

  type     rows_prod  est_rows  time       est_cost

  -------------------------------------------------

  nljoin   54564896   711570    1628:58.17   8698476

  type     table  rows_prod  est_rows  rows_scan  time       est_cost

  -------------------------------------------------------------------

  scan     t6     2182271    45000000  54564896   22:19.50   1      

  type     rows_prod  est_rows  time       est_cost

  -------------------------------------------------

  nljoin   2182271    28463     1630:48.99   10363743

  type     rows_prod  est_rows  rows_cons  time       est_cost

  ------------------------------------------------------------

  group    9          25        2182271    815:28.37   57707   

  type     rows_prod  est_rows  rows_cons  time

  -------------------------------------------------

  group    5          25        9          407:44.18

  type     rows_sort  est_rows  rows_cons  time       est_cost

  ------------------------------------------------------------

  sort     5          25        5          407:44.18   4      


实际结果的执行时间为407:44.18。执行计划前面部分,表的关系为嵌套并且都走了索引。

问题:

    1.嵌套时间1628:58.17肯定是不准备的,这时间如何计算出来,又如何知道真实的执行时间?

    2.rows_prod代表什么意思,与est_rows 和rows_scan的值相差较大,又说明什么?

    3. 统计信息刚执行完,为什么est_rows与rows_scan相差较大?

    4.scan   t5 的cost的值为1扫描行数很多,为何值这么小,且为1是因为全部内存scan么?

    5.综上信息能看出这条sql具体慢在哪里?

收起
参与14

查看其它 2 个回答junxi的回答

junxijunxi软件开发工程师nttdata

这个问题确实非常难以回答啊

软件开发 · 2016-09-05
  • 理解分析执行计划是调优基本手段。您如何分析执行计划呀。
    2016-09-06

回答者

junxi
软件开发工程师nttdata
擅长领域: 数据库GBase 8t国产数据库

junxi 最近回答过的问题

回答状态

  • 发布时间:2016-09-05
  • 关注会员:5 人
  • 回答浏览:819
  • X社区推广