Unix Technical Forum

view optimization.

This is a discussion on view optimization. within the DB2 forums, part of the Database Server Software category; --> I have a pretty complicated query containing several columns generted via olap windowing expressions. This query without any 'filtering' ...


Go Back   Unix Technical Forum > Database Server Software > DB2

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-28-2008, 04:39 AM
Purple-D
 
Posts: n/a
Default view optimization.

I have a pretty complicated query containing several columns generted
via olap windowing expressions. This query without any 'filtering'
where clauses would run in about 3-4 minutes. However the moment I add
a simple filtering clause like column_a = 20, the query would finish
in less than a second (due to different access plans)
i.e

select <lotsofcolumns>
from <lotsofjoins>
where <severaljoinconditions>
will finish in 4 mins.

select <lotsofcolumns>
from <lotsofjoins>
where <severaljoinconditions>
and column_a = 20 -- < Extra filter
will finish in < 1 sec.

My problem is I cannot put the extra filter in the query as it has to
sit behind a view which would add the required filters as needed

ie. create view view1 as (select <lotsofcolumns>
from <lotsofjoins>
where <severaljoinconditions>
);

select *
from view1
where column_a = 25
still takes 4 mins.

Is there a way to incorporate the additional clauses everytime the
view is run, i.e. somehow always re-compile the view at runtime taking
into account the additional clauses.

This is on DB2 9.1 FP2 on AIX

Thanks in advance for your help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-28-2008, 04:39 AM
Mark A
 
Posts: n/a
Default Re: view optimization.

"Purple-D" <passcore@gmail.com> wrote in message
news:c34d47c3-5a8a-4b30-b636-
> My problem is I cannot put the extra filter in the query as it has to
> sit behind a view which would add the required filters as needed


Why not? Just put the where clause on the SQL that accesses the view.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-03-2008, 02:47 PM
Purple-D
 
Posts: n/a
Default Re: view optimization.

On Mar 27, 8:42 pm, "Mark A" <nob...@nowhere.com> wrote:
> "Purple-D" <passc...@gmail.com> wrote in message
>
> news:c34d47c3-5a8a-4b30-b636-
>
> > My problem is I cannot put the extra filter in the query as it has to
> > sit behind a view which would add the required filters as needed

>
> Why not? Just put the where clause on the SQL that accesses the view.


It seems to run the 'view' first and then applies the where clause on
the result set and so the access plan is not as optimal as it would be
if the where clause were directly applied to the sql under the view.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:07 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com