Ian wrote:[color=blue]
>
lyn.duong@gmail.com wrote:
>[color=green]
>> Hi,
>>
>> I have a large table (about 50G) which stores data for over 7 years. I
>> decided to split this table up into a yearly basis and in order to
>> allow minimum changes to the applications which access this table, I
>> created a union all view over the 7 yearly tables.
>> What I have noticed is that queries against the union all view is
>> considerably slower than queries against the original table. When I ran
>> db2batch, I noticed cpu usage was higher + the number of piped sorts
>> was higher (proportional to the number of branches in my union all
>> view). Has anyone come across performance problems with union all views
>> and can offer some suggestions ??
>> I changed the locking level to TABLE for the read only year tables and
>> this helped a little bit.[/color]
>
>
> There are a couple of reasons to use UNION ALL views:
>
> 1) Query performance, which is achieved through branch elimination
> (branch = a table in the view).
>
> This really only applies if you decide how to break up your table with
> the queries in mind. If none of your queries against the view have
> predicates that allow for elimination of any of the branches you will
> likely see performance degradation.
>
> 2) Ease of maintenance (i.e. roll out an entire year's data very
> quickly).
>
> Implementing UNION ALL views for ease of maintenance can easily lead to
> performance problems like you describe. With proper planning (as Mark A
> described), you can minimize the impact of the design change on overall
> query performance.[/color]
Lyn,
Can you post the DDL, the slow query and the explain plan (ideally
either db2expln with the -graph option or a db2exfmt output?
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab