Gathering statistics for Materialized Views

In SQL Developer, the menu that you are presented by right-clicking a Materialized View does not give you a choice of collecting statistics, whereas you can analyze an MV and compute statistics at SQL command line. You can do that with the DBMS_STATS package too. Why is this so?

This is just an unintentional omission. I logged a task to get it added in our next full release.
-- Sharon

Similar Messages

  • Setting DBMS_METADATA.GET_DDL Output for Materialized Views

    Hi all.
    My Oracle version is 10g.
    I'm extracting the DDL of all the objects from database using the DBMS_METADATA package. I'm using SET_TRANSFORM_PARAM to configure the output because I need a simple sql code, without information about tablespaces, storage and segment attributes. Everything works fine except when I'm working with mviews object types. I can't remove the information about tablespace, storage or segment attributes for materialized views.
    I would like to know if there's a related issue about it. Or there's something missing in my code?
    I tried to specify the object type as another parameter on DBMS_METADATA.SET_TRANSFORM_PARAM but don't work too.
    The only transform parameter that works fine with Materialized Views is the SQLTERMINATOR.
    See how I have done:
    declare
    vDDL clob;
    begin
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'STORAGE', FALSE);
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'TABLESPACE', FALSE);
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', FALSE);
    dbms_metadata.set_transform_param (DBMS_METADATA.SESSION_TRANSFORM, 'SQLTERMINATOR',TRUE);
    select dbms_metadata.get_ddl ('MATERIALIZED_VIEW', 'MV_STO020', 'HIS117_CHECK') into vDDL FROM DUAL;
    dbms_output.put_line (vDDL);
    end;
    and how the output is:
    CREATE MATERIALIZED VIEW "HIS117_CHECK"."MV_STO020"
    ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TS_HIS117"
    BUILD IMMEDIATE
    USING INDEX
    REFRESH FORCE ON DEMAND
    WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE QUERY REWRITE
    AS SELECT
    STO020_MOVEMENT_LOG_ID STO020_MOVEMENT_LOG_ID
    , STO020_QUANTITY STO020_QUANTITY
    , STO020_DATE STO020_DATE
    , STO020_BEFORE_BALANCE STO020_BEFORE_BALANCE
    , STO011_PRODUCT_MOVEMENT_ID STO011_PRODUCT_MOVEMENT_ID
    , ADM082_PRODUCT_ID ADM082_PRODUCT_ID
    , ADM089_PRODUCT_PRESENTATION_ID ADM089_PRODUCT_PRESENTATION_ID
    , STO010_MOVEMENT_TYPE_ID STO010_MOVEMENT_TYPE_ID
    , STO001_STOCK_ID STO001_STOCK_ID
    , STO001_TARGET_STOCK_ID STO001_TARGET_STOCK_ID
    , STO003_PRODUCT_LOT_ID STO003_PRODUCT_LOT_ID
    , SYS010_USER_ID SYS010_USER_ID
    , EIR001_MPI EIR001_MPI
    , ADM056_MEDICAL_ATTENTION_ID ADM056_MEDICAL_ATTENTION_ID
    , ADM094_USE_UNIT_ID ADM094_USE_UNIT_ID
    FROM
    STO020_MOVEMENT_LOG;
    Thank you in advanced!
    Edited by: lucporto on 28/08/2012 07:26

    Right. I found this way but I consider this just a quick fix, because I think there should be a better way to do this.
    create table t_clob (c_long);
    declare
    p clob;
    begin
    delete from t_clob;
    execute immediate 'insert into t_clob (select to_lob(query) from dba_mviews where owner = :1 and mview_name = :2)'
    USING 'HIS117', 'MV_STO020';
    select 'CREATE MATERIALIZED VIEW MV_STO020' || chr(10) ||
    'REFRESH ON DEMAND' || chr(10) || 'AS' || CHR(10) || mv.c_long
    into p
    from t_clob mv;
    dbms_output.put_line(p);
    end;
    Thanks all.

  • Refresh time for Materialized View

    Hi,
    I have created a materialized view and set it to refresh everyday at 4 am . When I check the status of the job , it shows the refresh timing between 20 mins to 4 hours . That means , some times it takes 20 mins to refresh , some times 40 , some time 2 hours and some times up to 4 hours. Any reason for the wide range ? Here is the query for the view.
    CREATE MATERIALIZED VIEW BDS_COST_CATEGORY_MV
      ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"
      BUILD IMMEDIATE
      USING INDEX
      REFRESH COMPLETE ON DEMAND START WITH sysdate+0 NEXT ROUND(SYSDATE + 1) + 4/24
      USING DEFAULT LOCAL ROLLBACK SEGMENT
      DISABLE QUERY REWRITE
      AS    SELECT  AC.ACCOUNT_MANAGER, AC.ACCOUNT_NUMBER,
                    AC.ACCOUNT_NAME, DIV.DIVISION_NUMBER, ITEM.CODE_ID,
                    ITEM.CODE_NAME COST_CATEGORY_ITEM,
                    TO_NUMBER(TO_CHAR(AP.FIRST_DAY,'YYYY')) PERIOD_YEAR, 
                    AP.FIRST_DAY PERIOD,
                    SUM(NVL(AD.CURRENT_EXPENSE,0)) EXPENSE
            FROM ACCOUNTS AC, PERSONNEL AC_MGR, DIVISIONS DIV, ASR_HEADERS AH , ASR_DETAILS AD, CODES ITEM, CODES COSTCAT, ALL_PERIODS  AP,
                    CODES COST_ELEMENT, ACCOUNTING_BASE_GROUP ABG
            WHERE   AC.ACCOUNT_MANAGER = AC_MGR.PERSONNEL_ID
            AND     AC_MGR.DIVISION_ID = DIV.DIVISION_ID (+)
            AND     AC.ACCOUNT_ID = AH.ACCOUNT_ID
            AND     AH.ASR_HEADER_ID = AD.ASR_HEADER_ID
            AND     AH.PERIOD_ASR = AP.FISCAL_SYSTEM_PERIOD_CAL_YR_EQ||', '|| AP.FISCAL_YEAR
            AND     ABG.COST_ELEMENT_CAT_ITEM_ID = ITEM.CODE_ID 
            AND     COST_ELEMENT.CODE_ID = ABG.COST_ELEMENT_ID
            AND     AD.OBJECT_CODE = COST_ELEMENT.CODE_VALUE
            AND     ITEM.CODE_PARENT_ID = COSTCAT.CODE_ID
            AND     ( COSTCAT.CODE_NAME = 'BDS' OR ( COSTCAT.CODE_NAME = 'Base' AND ITEM.CODE_NAME = 'MTDC'))
            GROUP BY AC.ACCOUNT_MANAGER,AC.ACCOUNT_NUMBER, AC.ACCOUNT_NAME,
                     DIV.DIVISION_NUMBER, ITEM.CODE_ID, ITEM.CODE_NAME, 
                     TO_NUMBER(TO_CHAR(AP.FIRST_DAY,'YYYY')), AP.FIRST_DAY

    This appears to be a duplicate of Refreshing Materilized view. I replied on the other thread.
    Justin

  • Help needed in query for Materialized View

    Hi,
    I want to create a materialized view which has some precalcultaed values.
    I have four dimension tables out of which one is a Time Dimension table with levels as Year->Quarter->Month.
    The precalculations are the moving averages and cummulative values of Sales Amt on the dimension values over a period of 4 Months.
    The dimension tables are Clients, Products, Channel, Time.
    Fact Table is Sales_Fact which will have the sales amount for different members of the dimension.
    Since my fact table is very huge, i want to create a materialized view where i could store the required calculated measures, here Moving Average of Sales Amt for each Client, Product, Channel dimensions over a period of 4 Months.
    Can anybody help with writing the query for this..Any help in this regard will be appreciated..
    Please give me suggestions for this..

    Check this link.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
    Regards
    Raj

  • Explain Plan for Materialized Views in 10g

    I am verifying explain plan for few queries on 10g as compared to 9i I was wondering in Materialized Views queries MAT_VIEW ACCESS instead of TABLE ACCESS is it expected behaviour or am missing something?
    Couldn't find information in 10g documentation
    thanks in advance

    I've put together a query for the v$sql_plan in 9iR2.
    Depending on what you use, you can probably drop some columns (eg OTHER and partition columns) and you could drive it from the v$session by getting the hash_value from there for the sid you are interested in :
    (select * from v$sql_plan where hash_value =
    (select sql_hash_value from v$session where sid=:sid))
    select level, optimizer, lpad('_',1*(level-1),'_')||operation operation,
    options, object_owner||'.'||object_name obj_name, search_columns,
    ltrim(to_char(cardinality,'999,999,999')) no_rows,
    ltrim(to_char(bytes/1024,'999,999')) kbytes, cost tot_cost,
    object_node link, id, parent_id, other_tag||':'||other other,
    partition_start, partition_stop, cpu_cost, io_cost,
    access_predicates, filter_predicates,
    round(temp_space/(1024*1024),2) temp_space_mb
    from (select * from v$sql_plan where hash_value = :hash_val)
    start with id=0
    connect by prior id = parent_id and prior child_number = child_number
    order by child_number, id, position;

  • WHERE clause for Materialized View

    Hi,
    We are replicating a very large table from Production. The table is approx 40Gb in size and so the DBA's are very reluctant to do a full replication as it could bring down the production server (I'm a developer so I'm going on faith this is correct).
    I have been looking for a way to limit the number of columns that I need, approx 1 weeks data is enough to begin with. The table has a column txntimestamp which I am trying to use in the WHERE
    create materialized view FWWIPTRANSACTION                                                                                                                                                
    refresh fast on demand   with rowid 
      as select * from WLOS_OWNER.WAFPROD_FWWIPTRANSACTION
    where txntimestamp > '20/06/2009 07:00:00'But I recieve the error
    ORA-12015: cannot create a fast refresh materialized view from a complex queryDoes anyone know a way around this? This is the only date field I can use and pretty much the only viable option to limit the number of rows.
    Thank You.

    Sorry for jumping ahead but if I was able to get
    create materialized view FWWIPTRANSACTION                                                                                                                                                
    refresh fast on demand   with rowid 
      as select * from [email protected]
          where txntimestamp > '20/06/2009 07:00:00';to work, does this mean every time this MV refreshes it brings across everything since that date or merely the new rows since the last refresh? If so I will need a rolling clause i.e. sysdate - 30

  • Help for materialized View & Streams.

    Hi all,
    I am confused....I thought streams is replacing materialized view and replication :(
    What are the difference between "streams", "advance replication", and "mat. views"?
    Thanks a lot,
    zxy

    yxes2013 wrote:
    I'm in a rush deadline dear :(
    My boss ask me to replicate a table (with image column - picture of a person) which comes from sql server database to and oracle database.Well, presumably you informed your boss that you didn't know how to accomplish the task and that it would take some time for you to learn. And hopefully your estimates included sufficient padding to account for the fact that you'll be reading a lot of documentation.
    What do I do :( . Can I use mat. views + streams + advance repl? also dbvisit? Can you use materialized views? Sure.
    Can you use Streams? Sure.
    You could also use GoldenGate which is the technology Oracle has depricated Streams in favor of.
    I'm not sure that I see why you would want to use advanced replication unless you intend on doing bidirectional replication.
    I have no idea what dbvisit is. That doesn't sound like an Oracle technology.
    Justin

  • Refresh FAST for Materialized View failed after Partition Operation

    Dear all,
    I have created a Materialized View having a simple join between a Dimension and Fact Table of a Datawarehouse. The MV is REFRESH FAST ON DEMAND.
    However, when a Partition Maintenance Operation (PMOP) was performed on the Master Tables, the MV failed to Refresh giving a ORA-32313 error.
    As suggested on one of the troubleshooting websites, we did a complete refresh of the MV and fixed it temporarily. However, I would like to know the exact cause for this and would like to have a permanent fix for the same.
    Can the DBA for this Database provide me the answers or are there some standard troubleshooting steps for the same?
    Please let me know.
    Best,
    Ketan

    Hello Maurice,
    Here are the answers to your questions.
    1) Database is Oracle 9i.
    2) We have a stored procedure to refresh the MV. The command is dbms_mview.refresh('SALES_FACT_MV','f'). It was working fine daily. Only after a PMOP was done on the Master Tables, it failed to refresh. We have also created indexes on some columns of the MV for performance improvement. We are getting a very good improvement.
    3) We have MV logs for both Master Tables to store the incremental values.
    4) We are not able to get the output from DBMS_MVIEW.EXPLAIN_MVIEW since this can be done only by the DBA. WIll update you once I have the info.
    5) Same as Point 2.
    Let me know if you need any further info.
    Thanks, Ketan

  • What rights do I need for materialized views scheduling

    Hello,
    Can anyone tell me what rights do I need to schedule a materialized views at 1:00 am every night?
    To create material views I've use the folowing script:
    CREATE MATERIALIZED VIEW MV_view
    REFRESH COMPLETE
    START WITH sysdate NEXT round(SYSDATE + 1) + 1/24
    AS SELECT ... join tabeles... ;.
    The problem is that on my test server the MV_view run every night, but on production server my materialized views run only once (when I've run the script above).
    I have take a look into the user_refresh and in field NEXT_DATE it's the time of my MV_view creation.
    It is possible tha my DBA put some restrictions on my schema? Or do I need some rights to use START WITH and NEXT in my script on production server?
    Thanks,
    XaM

    Originally Posted by wyld
    Hi
    I find the correct method: I do not only assign reporting rights to htm , I need modify "Inventory report rights"of "Administrator task" in the left of ZCC Console.
    If I assign and modify the correct rights, he will create new & run these reports.
    wyldkao
    Which version you are using? I can't find Inventory Report Rights anywhere? I could only get this working by giving superadmin Please can some explain Thanks

  • Parameters in Init.ora for Materialized Views

    Fellow Experts,
    Are there any other parameters that I need to insert in the init.ora besides QUERY_REWRITE_ENABLED
    and
    QUERY_REWRITE_INTEGRITY
    once I create a materialize view ?
    Thanks.
    Ray.

    Oracle version 10.0.2 and the DDL that I'm planning to use might be simmilar to
    CREATE MATERIALIZED VIEW sales_by_month_by_state
    TABLESPACE example
    PARALLEL 4
    BUILD IMMEDIATE
    REFRESH COMPLETE
    ENABLE QUERY REWRITE
    AS SELECT t.calendar_month_desc, c.cust_state_province,
    SUM(s.amount_sold) AS sum_sales
    FROM times t, sales s, customers c
    WHERE s.time_id = t.time_id AND s.cust_id = c.cust_id
    GROUP BY t.calendar_month_desc, c.cust_state_province;

  • Dictionary for materialized view partitions

    Hi
    I created a materilaized view with partitions and i need to add partitions dynamicaaly using stored procedure for that i need to check whther the partiions with the same name existing.where can i see the partition names for a materilaized view is there any table like "USER_TAB_PARTITIONS"?.apologizes if the same query exists in the forum

    In your situation you can always query the dictionary ... using your experience/imagination regarding predicates.
    select *
      from dictionary
    where table_name like '%MVIEW%
        or table_name like '%PART%Regards
    Etbin

  • Dependencies (references) tab not working for materialized views.

    I am using SQL Developer version 1.2.0 Build 29.98. I also had this problem with version 1.1.
    I have created some materialized_views that are used by assorted packages, some of which are in other schema than the one that owns the materialized_view. When I select the specific materialized_view, then click on the 'Dependencies' tab, two displays appear. the first, 'Dependencies' is populated. The second 'References' is not. When I click on 'Refresh', nothing happens. I wrote my own query to see if there was a problem with the underlying data. The query shows me that the linkage data is there, linked to the TABLE object created to support the materialized_view object.
    SELECT
    i.owner AS input_owner,
    i.object_name AS input_name,
    i.object_id AS input_id,
    o.owner,
    o.object_name,
    o.object_id,
    o.TIMESTAMP,
    o.status
    FROM dba_objects i
    INNER JOIN
    public_dependency p
    ON (referenced_object_id = i.object_id)
    INNER JOIN
    dba_objects o
    ON (p.object_id = o.object_id)
    WHERE i.owner = :owner
    AND i.object_name = :object_name

    We finally got Office Web Apps installed and now the Most Popular is working.  Of course that means only when the documents are viewed in the Office Web App are they recorded for the Most Popular report.  We've done some testing and opening the
    file directly in the desktop application, or even editing the file directly in the desktop application are never recorded.  My one disclaimer with this is we are using Office 2010, I'm curious if Office 2013 perhaps records views and edits using the desktop
    application?
    Luckily the latest OWA patch now allows PDF's to open in the Word Office App as well, so those views are recorded.  If you have any non office or non PDF in the library, views will not be recorded for these items unfortunately.
    I can't believe how this isn't documented anywhere. 
    Nick Hurst

  • Disabling Materialized View Logs for a session

    Hi all.
    I was wondering if it is possible to disable the fast refresh log for materialized views for just a given session. So for all other sessions except this one the log would be added to. I'm using 11g.
    In Oracle Database 11g, The Complete Reference on page 447 it states:
    "As of Oracle 11g, the capture of changes in materialized view logs can be disabled for an individual session while logging continues for changes made by other sessions". But no instructions are given
    Does anyone know how to do this? I have not been able to find the answer by looking around.
    Thanks!

    Yeah, I had saw that Oracle mentioned it here also: http://download.oracle.com/docs/cd/B28359_01/server.111/b28279/chapter1.htm#FEATURENO07197
    Any idea of what the code might look like? I've never had to alter an individual session for Oracle before.

  • Map Viewer Query Rewriting for Dynamic themes and  Materialized Views.

    Hi,
    I am usng a WMS request to render FOI points in my map.
    Internally query rewrite is happening in Mapviewer for this dynamic theme and my data points query is getting converted as
    select FROM
    ( select status, shape from MatView.MyTab where id = '3' )
    WHERE MDSYS.SDO_FILTER(shape, MDSYS.SDO_GEOMETRY(2003, 4283, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3), MDSYS.SDO_ORDINATE_ARRAY(144.948120117188,-37.8162934802451,144.950866699219,-37.8141237016045)), 'querytype=WINDOW') = 'TRUE'
    here the rewritten query is not correct and is throwing exceptions in mapviewer log
    How can I make this query to be written correctly.
    (My orginal query before rewrite is: select status,shape from MatView.MyTab where id='3' )
    I am using a materialised view : MatView is a materialized view.
    When I used normal tables, the query is re written correctly.But for this materialized view this is happening.
    How can I correct the error?
    Is this has something to do with some Spatial Indexing in Materialised view or Query Rewriting for materialized view?
    Edited by: 841309 on Mar 10, 2011 11:04 PM

    Oops!
    The Materialized view was not accessible from the schema I tried :)
    And so when I gave permissions,it formed the correct query.
    So if permission is not there,map viewer will rewrite the query in a wrong way! New information.

  • Fast refresh on MATERIALIZED VIEW

    Oracle 10 g R2 (10.2.0.5)
    CREATE MATERIALIZED VIEW scott.mv_test
    TABLESPACE users
    NOCACHE
    LOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH FORCE ON DEMAND
    WITH PRIMARY KEY
    AS
    Select ....
    I have this MV, when I do the FAST refersh as follows , I am getting error
    SQL> execute DBMS_MVIEW.REFRESH( 'MV_TEST','f');
    BEGIN DBMS_MVIEW.REFRESH( 'MV_TEST','f'); END;
    ERROR at line 1:
    ORA-12004: REFRESH FAST cannot be used for materialized view "SCOTT"."MV_TEST"
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2251
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2457
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2426
    ORA-06512: at line 1
    But it's working with Complete refresh.
    Is that expecte, any help would be appreciated.
    Thanks,

    ORA-12004: REFRESH FAST cannot be used for materialized view "string"."string"
    Cause:      The materialized view log does not exist or cannot be used. PCT refresh is also not enabled on the materialized view
    Action:      Use just REFRESH, which will reinstantiate the entire table. If a materialized view log exists and the form of the materialized view allows the use of a materialized view log or PCT refresh is possible after a given set of changes, REFRESH FAST will be available starting the next time the materialized view is refreshed.http://ora-12004.ora-code.com/

Maybe you are looking for