view optimization.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Purple-D

    #1

    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 <lotsofcolumn s>
    from <lotsofjoins>
    where <severaljoincon ditions>
    will finish in 4 mins.

    select <lotsofcolumn s>
    from <lotsofjoins>
    where <severaljoincon ditions>
    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 <lotsofcolumn s>
    from <lotsofjoins>
    where <severaljoincon ditions>
    );

    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!
Working...