DB2查看執行計畫

來源:互聯網
上載者:User

DB2查看執行計畫

在DB2中查看sql的執行計畫沒有其它資料庫方便,需要經過好幾步,這裡我把步驟整理成shell指令碼以方便使用,如下:

#!/bin/sh
 
db2 connect to <db>
db2 -tvf $HOME/sqllib/misc/EXPLAIN.DDL
db2 set current explain mode explain
 
db2 "
<sql>
"
 
db2 set current explain mode no
 
db2exfmt -d <db> -g TIC -w -l -s % -n % -o explain.out

使用時需要替換掉指令碼中的db和sql

本文永久更新連結地址:

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.