View previous topic :: View next topic |
Author |
Message |
Cogito-Ergo-Sum Advanced
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
|
Posted: Fri Aug 10, 2007 3:45 am Post subject: Unload approach : Table with WHERE condition or a View. |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Fri Aug 10, 2007 6:11 am Post subject: |
|
|
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 |
|
|
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Fri Aug 10, 2007 10:18 am Post subject: |
|
|
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 |
|
|
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Fri Aug 10, 2007 10:26 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Fri Aug 10, 2007 10:38 am Post subject: |
|
|
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 |
|
|
Cogito-Ergo-Sum Advanced
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
|
Posted: Sat Aug 11, 2007 11:35 pm Post subject: |
|
|
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 |
|
|
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Mon Aug 13, 2007 7:59 am Post subject: |
|
|
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 |
|
|
Cogito-Ergo-Sum Advanced
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
|
Posted: Mon Aug 13, 2007 7:04 pm Post subject: |
|
|
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, 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 |
|
|
|
|