MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Unload approach : Table with WHERE condition or a View.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Fri Aug 10, 2007 3:45 am    Post subject: Unload approach : Table with WHERE condition or a View. Reply with quote

Hi,
In general, would it be faster to unload a table which has WHERE conditions applied to it or a View built with the same WHERE condition ?

In my case, I have to unload from a join of two H U G E tables and then apply WHERE conditions one of which is a date function, as
Code:
B.DISCONNECTION_DATE >= CURRENT DATE - 190 DAYS


Therefore, I am thinking of creating a VIEW created out of the join of tables and then applying the WHERE conditions that I would have to apply to the table join.

PS: I am using BMC UNLOAD - if it helps.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri Aug 10, 2007 6:11 am    Post subject: Reply with quote

Cogito-Ergo-Sum,

I would use a correlated sub-query to get the date instead of it excueting it for every row.
Code:

B.DISCONNECTION_DATE >= (SELECT CURRENT DATE - 190 DAYS
                           FROM SYSIBM.SYSDUMMY1)


A 2 table joined view wouldn't that effective in terms of unloading.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Fri Aug 10, 2007 10:18 am    Post subject: Reply with quote

kolusu wrote:
Cogito-Ergo-Sum,

I would use a correlated sub-query to get the date instead of it excueting it for every row.
Code:

B.DISCONNECTION_DATE >= (SELECT CURRENT DATE - 190 DAYS
                           FROM SYSIBM.SYSDUMMY1)


A 2 table joined view wouldn't that effective in terms of unloading.

Kolusu


You could just use
B.DISCONNECTION_DATE >= (CURRENT DATE - 190 DAYS)
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Fri Aug 10, 2007 10:26 am    Post subject: Reply with quote

I'm looking at the BMC Unload manual and it looks like you can only unload from a single table, no joins. I don't have BMC utilities to try this. Does BMC allow the joining of tables in the Unload utility?

Here's a link to their Unload manual.

http://documents.bmc.com/supportu/documents/10/66/71066/71066.pdf
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri Aug 10, 2007 10:38 am    Post subject: Reply with quote

Quote:

You could just use
B.DISCONNECTION_DATE >= (CURRENT DATE - 190 DAYS)


Craig,

Wouldn't this condition get execueted for every row unloaded? MY suggestion was to use the Subquery to avoid that.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Sat Aug 11, 2007 11:35 pm    Post subject: Reply with quote

Kolusu,
Thanks.

I think, I will have a SORT step to get the (CURRENT DATE -190 DAYS) and pass it to the unload card so that the evaluation is removed altogether.

jsharon1248,
Yes, you can. Look at the DIRECT option in the UNLOAD statement. I think the default value was YES that does not allow standard SQL statements - in other words, WHERE clause. With DIRECT NO, you can have WHERE clauses, etc. However, the usage of DIRECT NO causes a trade-off with performance.

Actually, this is the reason, I posted this question. I thought of using UNLOAD with DIRECT YES (to utilize best performance). Since, I have two tables here, I thought of constructing a VIEW and then use UNLOAD with DIRECT YES on the whole VIEW.

PS: I tried replying earlier. I kept getting 'Invalid Session. Please resubmit the form.' message.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Mon Aug 13, 2007 7:59 am    Post subject: Reply with quote

Thanks for the followup. I reviewed the DIRECT=NO option and it's exactly as you stated.

I have my doubts that you'd be able to trick the utility by using a view to 'hide' the join. I'm pretty sure that BMC reads directly from the tablespace dataset when you specify DIRECT=YES. That being said, you're not going in through the DB engine. Even if the tables in the view are in the same tablespace, I don't think BMC will be able to do the work without developing an access path and all that. It's certainly worth a try, but you might be forced to use an alternative. I'll be interested to see what you find.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Aug 13, 2007 7:04 pm    Post subject: Reply with quote

jsharon1248,
I have been never good in the DB2 "internals" and the ways these utilities work.

I am not exactly "chums" with our DBAs nowadays, Mr. Green So, it will be quite sometime until I set up the test to report on.

Thanks anyway !
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group