If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > db2expln and access plans

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-03-09, 11:29
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
db2expln and access plans

DB2 V9.5 on windows....

I know how to do an access plan against SQL text and get a graph back... how do I run it from the command editor and get the access plan back in text????
Reply With Quote
  #2 (permalink)  
Old 04-03-09, 13:00
dbamota dbamota is offline
Registered User
 
Join Date: Sep 2003
Posts: 237
db2expln -database crm -stmtfile q -terminator ";" -t > outputfile

works in unix; must be similar in windows
put your sql in stmtfile and end the sql with a ;
crm is the database name; look at db2expln command
__________________
mota
Reply With Quote
  #3 (permalink)  
Old 04-03-09, 13:36
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
Thanks! IS there a way to run a SHOW PLAN or EXPLAIN from the GUI and then save it to a file?????
Reply With Quote
  #4 (permalink)  
Old 04-06-09, 09:14
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
I am still kind of struggling with this.

Developer sent me some poorly running SQL (he did not write it) and asked me to do an explain on the SQL for him.

I can run it through access plans via the GUI - but that is graphical and I can't sent it to him.

I think I need to use db2expln. I am running on DB2 V9.5 on wondows. From what I've read, it looks like db2expln is command line only.

I'm read through the syntax for db2expln so many times ( in the manual ) that my head is spinning.

Can anyone guide me as what I need to do in order to run this long-a** chunk of SQL through db2expln???
Reply With Quote
  #5 (permalink)  
Old 04-06-09, 09:32
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
Quote:
Originally Posted by itsonlyme44
DB2 V9.5 on windows....

I know how to do an access plan against SQL text and get a graph back... how do I run it from the command editor and get the access plan back in text????
run it with -graph option and you will get a graph you can copy and paste
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #6 (permalink)  
Old 04-06-09, 09:34
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
I don't necessarily NEED a graph.. just not sure how to run the SQL that he sent me in the body of an email through DB2EXPN?
Reply With Quote
  #7 (permalink)  
Old 04-06-09, 09:41
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
Quote:
Originally Posted by itsonlyme44
I don't necessarily NEED a graph.. just not sure how to run the SQL that he sent me in the body of an email through DB2EXPN?
then dbamota explained it how to do it - put it in file, finish with ; and run explain.
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #8 (permalink)  
Old 04-06-09, 09:44
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
Thank you. I will try and figure it out
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On