Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Dynamically recreating indexes on materialized views

Re: Dynamically recreating indexes on materialized views

From: Jaap W. van Dijk <j.w.vandijk.removethis_at_hetnet.nl>
Date: Wed, 08 Mar 2006 10:30:29 GMT
Message-ID: <440eb134.1096656@news.hetnet.nl>


On Wed, 8 Mar 2006 16:13:01 +1100, Geoff Muldoon <geoff.muldoon_at_trap.gmail.com> wrote:

>Hi all,
>
>On a pair of separate Linux boxes, instances or 9.2 (prod) and 10g (dev),
>would prefer a solution that could work on both versions.
>
>I use a cron'd PL/SQL procedure which calls DBMS_MVIEW to refresh a series
>of materialized views each night - complete refresh needed on most as
>there is aggregation in the MV sources.
>
>I am convinced that I will (eventually as data size grows, if not already
>on some) need to drop all the indexes on these materialized views, then
>refresh them, then recreate the indexes.
>
>I would like to use a process which will allow for changes to the indexing
>strategy without the need for any re coding.
>
>Pseudo-code something like:
>
>cursor mvs is
> <ordered list of materialized views to be refreshed>
>cursor mv_indexes is
> <select index names from user_indexes for current mv>
>cursor mv_index_ddls is
> <select DDL text from temp DDL table for indexes for current mv>
>begin
> <for mv in mvs loop>
> -- load DDLs for index for this mv into temp table
> -- using select DBMS_METADATA.GET_DDL
> <load the values into the temp DDL table for this mv>
> -- drop all the indexes on this mv
> <for mvi in mv_indexes loop>
> <exec immediate drop the index>
> <end loop>
> <DBMS_MVIEW.REFRESH(current mv, 'C')>
> -- recreate the indexes on current mv
> <for mvid in mv_index_ddls loop>
> <exec immediate create the index>
> <end loop>
> <end loop>
>end;
>
>Is this the recommended way to go, or am I way off track?
>
>Geoff M
>
>

Instead of

you could

Much more robust.

Jaap. Received on Wed Mar 08 2006 - 04:30:29 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US