Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / March 2008

Tip: Looking for answers? Try searching our database.

view optimization.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Purple-D - 27 Mar 2008 23:16 GMT
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!
Mark A - 28 Mar 2008 01:42 GMT
"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.
Purple-D - 28 Mar 2008 13:59 GMT
> "Purple-D" <passc...@gmail.com> wrote in message
>
[quoted text clipped - 4 lines]
>
> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.