Fragmentation in Materialized Views

Hi,
Can fragmentation in materialized views will happen, when base table has lots of deletes. I created a simple materialized view for a base fact table which will have daily deletes (same no as inserts). Due to fragmentation the queries for this table are getting executed slowly. If fragmentation happens even in MViews then this idea is not helpful.
Appreciate someone help in this regard and clarify my doubt.
Thanks,
Raju.

change the base table and use execute dbms_mview.refresh('matview name')What change you made? Did you recreate the table or altered the structure(dropped the column)? If so, I think you should get the error in the refresh path. Is it so or it is just taking time?
Regards

Similar Messages

  • Equivalent of Materialized Views in SQL Server

    Hi
    we are migrating  Oracle Database to SQL Server 2012 and is looking for solution, equivalent to Materialized Views in Oracle.
    we had tried to implement indexed View, but that was not possible, because the MVs have outer joins, subqueries, aggregate functions and also there is no column in it which can act as a Primary Key.
    Please Help to get a solution for this issue.
    Regards
    Joyasree Mondal

    >use tempdb
    >drop table t
    >go
    >create table t(id int, constraint pk_t primary key (id))
    >
    >go
    >insert into t(id)
    >select top 1000 cast( cast( newid() as binary(4) ) as int)
    >from sys.objects o, sys.columns c
    >go 100
    >
    >
    >select id
    >from t with (index=pk_t, tablockx)
    >
    >
    >select id
    >from t with (index=pk_t, nolock)
    Still the same order.
    >> No, its always in the key order like I've shown here.
    > You are extrapolating from a single example.
    Actually, this information doesn't even come from my exampleS (there were quite a few so far). Its written in the article you posted here. My examples are meant to confirm that and explain why the ORDER BY clause is redundant in some cases.
    > I have.  ORDER BY in a view used to always return ordered results.  Then it didn't.
    Examples? References?
    >GROUP BY without an ORDER BY used to always return ordered results.  Then it didn't.  Many queries have >change the result ordering when you get a parallel plan.
    Now you finally admit ordered results would always be returned, even without an order by clause. We are in the right track it appears. The reason for this change of behavior is a variation in the logical operator used by the query optimizer, and not the
    way the engine reads pages from disk.
    In the beginning of times there was stream aggregate, an operator that would require its input to be sorted. And this is how a GROUP BY clause would ensure results were always ordered.
    But then his ugly cousin came and messed things up. He doesnt need an ordered input so yeah, order would be random. AGAIN, there are still ways of enforcing order here, through query hints, without requiring an order by clause, so this changes nothing.
    You have confirmed that for a given operator, results will always be ordered. Your own argument has, once again, proven my point.
    > Right.  But there are different _kinds_ of scans.  An ordered scan, where SQL Server reads rows based on the logical order of the index is just one kind. 
    It only won't scan in key order (by scheduling reads) if you change the transaction isolation level and hope for the worse. Because the key order scan is the best performing way of reading pages, this behavior (although possible) wasan't even observed in
    the example with NOLOCK/TABLOCK (known to cause allocation-order scans in larger tables) you posted above.
    > Other kinds include the parallel scan, the reverse scan,
    References?
    > the merry-go-round scan,
    Only applies to table scans, not indexes.
    http://technet.microsoft.com/en-us/library/ms191475%28v=SQL.105%29.aspx
    > And the allocation-order (or unordered) scan. 
    Only if you specify TABLOCK or NOLOCK query hints, which I haven't done. This is something that goes without saying, it's irrelevant to an indexed view scenario such as this one.
    Some people have also said it will perform an allocation-order scan if the index is too fragmented in SQL Server 2005, but as of 2012 it (probably) won't, as I have shown here. There is also no document anywhere in the internet (you are free to search for
    it), that would point us otherwise. If you have access to additional information, I would be more than happy if you could share it with us.
    Reference: http://sqlmag.com/database-development/quaere-verum-clustered-index-scans-part-iii
    > And don't take my word for it.  Take Conor Cunningham's:
    >If you need order in your query results, put in an ORDER BY.  It's that simple.  Anything else is like >riding in a car without a seatbelt.
    >No Seatbelt - Expecting Order without ORDER BY
    Again, with all due respect, did you read your own article? Did you read what I said earlier about having multiple I/O threads as a whole other situation? If you add new variables, OF COURSE the results will be different. Parallelism was disabled in the
    server I performed these tests on, but still you can control this by query hints, and you can enforce execution plans by using plan gudes.
    Its like I always say - it's always about the 0.001% of situations, the exceptions, rather than the general rule.
    Tell Mr Connor to add MAXDOP 1 to his querys OPTION clause and see if results are still unordered lol
    References:
    http://msdn.microsoft.com/en-us/library/ms190417.aspx
    http://msdn.microsoft.com/en-us/library/ms181714.aspx
    http://technet.microsoft.com/en-us/library/ms188611%28v=sql.105%29.aspx
    http://blogs.msdn.com/b/conor_cunningham_msft/archive/2008/08/27/no-seatbelt-expecting-order-without-order-by.aspx
    Imagining uncontrollable factors that would get an ordered input to be retrieved in an unordered manner is one of SQL Server's myths. There are a whole other people around who think the same way because of some experiences they had when they didn't know
    how to control the execution plan, and adding an order by clause is a very popular and easy shortcut to a complex problem. "In the worst cases it will just be redundant", they say. What they like to forget is that sorting has an often high cost,
    and it can be avoided by taking advantage of indexes.

  • Materialized view logs issue

    We are having issues with the size of materialized view logs in one od the database. The size of the log table is around 32G. Will appreciate if somebody will help in explaining why it is having such a huge size and is not getting purged.
    At the same time the master table is having comparatively smaller size of 18G(did not check table fragmentation).
    Also, please help me in understanding what is required to be done for fixing this issue.
    SQL> select LOG_OWNER,MASTER,LOG_TABLE,LOG_TRIGGER,PRIMARY_KEY from dba_mview_logs where log_owner='MARTDATA' and MASTER='POLICY_CONFIGURATION';
    LOG_OWNER MASTER LOG_TABLE LOG_TRIGGER PRI
    MARTDATA POLICY_CONFIGURATION MLOG$_POLICY_CONFIGURATION NO
    SQL> select owner, segment_name, sum(bytes)/1024/1024 "SIZE in MB" from dba_segments where segment_name='POLICY_CONFIGURATION' and owner ='MARTDATA' group by owner, segment_name;
    OWNER SEGMENT_NAME SIZE in MB
    MARTDATA POLICY_CONFIGURATION 18458
    SQL> select owner, segment_name, sum(bytes)/1024/1024 "SIZE in MB" from dba_segments where segment_name='MLOG$_POLICY_CONFIGURATION' and owner ='MARTDATA' group by owner, segment_name;
    OWNER SEGMENT_NAME SIZE in MB
    MARTDATA MLOG$_POLICY_CONFIGURATION 32298
    Thanks

    Oracle automatically purges rows in the materialized view log when they are no longer needed. Because Oracle must wait for all dependent materialized views to refresh before purging rows from a materialized view log, unwanted situations can occur that cause a materialized view log to grow indefinitely when multiple materialized views are based on the same master table or master materialized view.
    For example, such situations can occur when more than one materialized view is based on a master table or master materialized view and one of the following conditions is true:
    Materialized view is not configured for automatic refreshes and has not been manually refreshed for a long time. OR
    Materialized view has an infrequent refresh interval, such as every year, etc
    You can also refresh the materialized views associated with the log so that Oracle can purge rows from the materialized view log.
    If a materialized view log needs to be purged manually for some reason a procedure called DBMS_MVEW.PURGE_LOG can be used.
    Edited by: user130038 on Sep 30, 2011 6:49 AM

  • Refresh/Update data in a materialized view

    Hi,
    I have question about the data in a materialized view and how it is refreshed. My mat view has all my dimension-ids and my (for my specialize needs) aggregated measures from my fact table. I used the mat view wizard to create my view - which works perfectly. But now I wonder if I have to create some sort of mapping(?) or some sort of trigger to refresh the data in the mat view. Or is the data automatically refreshed when I start my fact table mappings. I use OWB 11gR2
    thx

    MVs have properties for refresh - you an refresh based on schedules or when dependent data is committed or manually.
    Cheers
    David

  • How can I fast refresh the  materialized view !!

    I created a MV base on some tables in order to improve the querey speed.
    but the mv I have created falied to refresh fast.
    because there are two same table in the from clause:
    jcdm jc1,jcdm jc2
    create materialized view temp_mv
    nologging
    pctfree 0
    storage (initial 2048k next 2048k pctincrease 0)
    parallel
    build immediate
    refresh force
    on demand
    as
    select
    TAB_GSHX.rowid hx_rid,
    TAB_GSHD.rowid hd_rid ,
    JC1.rowid jc1_rid ,
    JC2.rowid jc2_rid ,
    YSHD_ID     HXID,          
    JC1.JCDM     QFD,     
    JC2.JCDM     JLD     
    FROM
    TAB_GSHX,
    TAB_GSHD,
    jCDM JC1,
    JCDM JC2
    WHERE
    YSHD_ID=YSHX_ID
    AND YSHD_QFD=JC1.JBJC_ID
    AND YSHD_JLD=JC2.JBJC_ID
    AND TO_CHAR(YSHX_time,'YYYYMMDD')='20030101'
    the column msgtxt of the table MV_CAPABILITIES_TABLE is :
    "the multiple instances of the same table or view" and " one or more joins present in mv".
    How can I succeed in fast refresh the above temp_mv!!!
    thanks.

    lianjun,
    When you are using Oracle9i there is a procedure which can help you setup the materialized view. If some option isn't working it gives you hint why it doesn't work.
    The procedure is dbms_mview.explain_mview.
    Take a look at the documentation how to use it. (In the Oracle9i DWH guide the package is explained.)
    Hope this helps
    With kind regards,
    Bas Roelands

  • How to get Materialized View to ignore unused columns in source table

    When updating a column in a source table, records are generated in the corresponding materialized view log table. This happens even if the column being updated is not used in any MV that references the source table. That could be OK, so long as those updates are ignored. However they are not ignored, so when the MV is fast refreshed, I find it can take over a minute, even though no changes are required or made. Is there some way of configuring the materialized view log such that the materialized view refresh ignores these updates ?
    So for examle if I have table TEST:
    CREATE table test (
    d_id NUMBER(10) PRIMARY KEY,
    d_name VARCHAR2(100),
    d_desc VARCHAR2(256)
    This has an MV log MLOG$_TEST:
    CREATE MATERIALIZED VIEW LOG ON TEST with rowid, sequence, primary key;
    CREATE MATERIALIZED VIEW test_mv
    refresh fast on demand
    as
    select d_id, d_name
    from test;
    INSERT 200,000 records
    exec dbms_mview.refresh('TEST_MV','f');
    update test set d_desc = upper(d_desc) ;
    exec dbms_mview.refresh('TEST_MV','f'); -- This takes 37 seconds, yet no changes are required.
    Oracle 10g/11g

    I would love to hear a positive answer to this question - I have the exact same issue :-)
    In the "old" days (version 8 I think it was) populating the materialized view logs was done by Oracle auto-creating triggers on the base table. A "trick" could then make that trigger become "FOR UPDATE OF <used_column_list>". Now-a-days it has been internalized so such "triggers" are not visible and modifiable by us mere mortals.
    I have not found a way to explicitly tell Oracle "only populate MV log for updates of these columns." I think the underlying reason is that the MV log potentially could be used for several different materialized views at possibly several different target databases. So to be safe that the MV log can be used for any MV created in the future - Oracle always populates MV log at any update (I think.)
    One way around the problem is to migrate to STREAMS replication rather than materialized views - but it seems to me like swatting a fly with a bowling ball...
    One thing to be aware of: Once the MV log has been "bloated" with a lot of unneccessary logging, you may perhaps see that all your FAST REFRESHes afterwards becomes slow - even after the one that checked all the 200000 unneccessary updates. We have seen that it can happen that Oracle decides on full table scanning the MV log when it does a fast refresh - which usually makes sense. But after a "bloat" has happened, the high water mark of the MV log is now unnaturally high, which can make the full table scan slow by scanning a lot of empty blocks.
    We have a nightly job that checks each MV log if it is empty. If it is empty, it locks the MV log and locks the base table, checks for emptiness again, and truncates the MV log if it is still empty, before finally unlocking the tables. That way if an update during the day has happened to bloat the MV log, all the empty space in the MV log will be reclaimed at night.
    But I hope someone can answer both you and me with a better solution ;-)

  • Materialized View to run only once in a year...

    Hi everybody...
    I want to create a materialized view which will run only once in a year and specifically some minutes after 00:00 a.m. on new year's day,
    so i created the following:
    CREATE MATERIALIZED VIEW <mv_name>
    BUILD IMMEDIATE
    REFRESH START WITH TO_DATE('01/01/2007 00:15:00','DD/MM/RRRR HH24:MI:SS')
    NEXT SYSDATE+366
    I have two notes:
    1) how to declare the refresh to be done the first new year's day after the day it'll be created , i mean not static date (01/01/2007)
    2)some years are leap and some are not , so in order to run every new year's day how should i transform the above..????
    3)is there any view which displays the next run of a materialized view..???
    the view DBA_MV_REFRESH_TIMES displays the last refresh of mv's...
    I use Oracle 10.2.0.1 on XP ...
    Thanks , a lot
    Simon

    1).
    use the expression that evaluates to next january first.
    SQL> select sysdate, add_months(trunc(sysdate, 'yyyy'), 12) from dual ;
    SYSDATE     ADD_MONTHS(
    19-JUN-2006 01-JAN-2007
    1 row selected.
    SQL>2). for this also use the same expression that will evaluate to the january first of the year after that.

  • Is it possible to refresh the table from a Materialized view

    Hi,
    Is it possible to update the underlying table on which a Materialized view is created when some changes in a Materialized view is done.Is this reverse compatibility possible in Materialized View?
    Thanks in Advance,
    V.Dennis

    If you created the materialized view as UPDATEABLE then changes to it should automatically be relected in the underlying table. If this is not occurring I suggest you check the replication jobs. You probably have a stack of errors in DEFERROR.
    Cheers, APC

  • The data of my materialized view....in the while

    Hello
    We have problems with materialized views
    We have one wich re-build each a short period of time
    ¿Can i avoid the data to dissapear in the time process of refresh?
    Is so annoing to our clients to see that "from time to time" the data just dissapear for one period of time -the time while the materialized view is refreshing-
    Thank you in advance
    Bruno. Madrid. Spain

    > Is so annoing to our clients to see that "from time to time" the data just dissapear for
    one period of time -the time while the materialized view is refreshing-
    Have a similar problem. And dealing with large data volumes that makes the DELETE of the MV a very undesirable feature. Not as much a the resource footprint required, but the time it takes to do this - and the very tight processing windows that exist.
    The solution is a self-rolled and very likely not ideal for most - but it works well enough for us in production.
    No MV. Create a partition table. Create a staging table. Do a manual "full refresh" of the staging table (TRUNCATE and direct path INSERT). Follow this by a partition exchange with the partition table (no validation and including indexes). The result is that the data is replaced in the partitioned table within a second - no long running and expensive DELETE. End-users not effected by having a truncate pulling the data from beneath their reports.

  • Exporting data from a materialized view in Oracle 10g

    Can anybody tell me how to export data to a remote server and import data in that remote server without using ftp utility. Actually I want to export the data from a materialized view to the remote server and import the same in the remote server.
    If everything works well, I'll put the exporting and importing in a cronjob.
    Please let me know how can I do that if that's possible .
    Any reply would be appreciated.
    Thanks.

    Here is what I'm trying to do.
    I created materialized views using multiple base tables in my local server and the base tables got populated using a long process.
    Now I want to copy those data alone to some remote server since it doesn't have any base tables in it. For now, the remote server should depends on the localserver's data. I'm going to use the remote server's data for some testing purposes.
    I know it is easy to create mat.views in the remote server but it doesn't have I don't want to do that now. I just want to copy the snapshots from my local server to the remote server.
    Please let me know how to do that.
    Thanks.

  • Issue with creation of a materialized view

    Hi,
    I have a SQL query that works fine.
    But when I create a materialized view using the query, a few columns in the MV do not get populated at all.
    What could be the issue here?
    regards
    Prem

    Hi,
    Thanks for the reply. Here is the code.
    CREATE MATERIALIZED VIEW EDW.MV_OPPTY_ACTIVITY_AGG
    TABLESPACE EDW_DIM_DAT
    NOCACHE
    LOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH COMPLETE ON DEMAND
    WITH PRIMARY KEY
    AS
    select
    OPPTY_ID OPPTY_ID,
    OPPORTUNITY_KEY OPPORTUNITY_KEY,
    oppty_number oppty_number ,
    SALES_CONSULTANT_HIST_KEY SALES_CONSULTANT_HIST_KEY ,
    company_add_source_key company_add_source_key,
    SALES_CONSULTANT_ID SALES_CONSULTANT_ID,
    ACTIVITY_TYPE ACTIVITY_TYPE ,
    activity_DATE activity_DATE ,
    LAST_MODIFIED_DATE LAST_MODIFIED_DATE ,
    CUSTOMER_FLAG CUSTOMER_FLAG,
    SALES_EMPLOYEE_HIST_KEY,
    milestone_KEY,
    oppty_milestone_name_hist stage_name,
    oppty_milestone_id_hist stage_id,
    milestone_prob prob_to_close,
    start_date oppty_start_date,
    oppty_close_date oppty_close_date,
    end_date oppty_end_date,
    sum(DURATION) TOTAL_DURATION,
    sum (CASE WHEN ACTIVITY_type IN ('CU14', 'CU15', 'CU16', 'CU17',
    'CU18', 'CU19', 'CU20', 'CU21') THEN DURATION ELSE 0 END ) CQM_DURATION,
    sum (CASE WHEN ACTIVITY_type = 'CU01' THEN DURATION ELSE 0 END ) TRADE_SEM_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU02' THEN DURATION ELSE 0 END ) RFP_RFI_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU03' THEN DURATION ELSE 0 END ) INFO_GATH_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU04' THEN DURATION ELSE 0 END ) PREP_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU05' THEN DURATION ELSE 0 END ) PRES_DEMO_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU06' THEN DURATION ELSE 0 END ) POC_DURATION,
    sum ( CASE WHEN ACTIVITY_type = 'CU07' THEN DURATION ELSE 0 END ) PRE_CUST_SUPP_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU08' THEN DURATION ELSE 0 END ) POST_CUST_SUPP_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU09' THEN DURATION ELSE 0 END ) PARTNER_SUPP_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU10' THEN DURATION ELSE 0 END ) TRAVEL_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU11' THEN DURATION ELSE 0 END ) KEYCODES_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU12' THEN DURATION ELSE 0 END ) SI_SUPP_DURATION,
    sum ( CASE WHEN ACTIVITY_type = 'CU13' THEN DURATION ELSE 0 END ) CHANNEL_SUPP_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU23' THEN DURATION ELSE 0 END ) MIGRATION_DURATION ,
    max(LICENSE_USD) LICENSE_USD ,
    MAX(LICENSE_LOCAL) LICENSE_LOCAL,
    MAX(maintAINANCE_usd) maintAINANCE_usd,
    MAX(maintAINANCE_LOCAL) maintAINANCE_LOCAL,
    MAX(TRAINING_USD) training_usd,
    MAX(TRAINING_LOCAL) training_LOCAL,
    MAX(CONSULTING_USD) consulting_usd,
    MAX(CONSULTING_LOCAL) consulting_LOCAL,
    MAX(RENEWALS_USD) renewals_usd ,
    MAX(RENEWAL_local) RENEWAL_local,
    max(LOBANALYTICS2_LOCAL) epm_local,
    max(LOBDATAINTEGRATION2_LOCAL) eim_local,
    max(IDD_AMOUNT_LOCAL) idd_local,
    max(ONDEMAND_AMOUNT_LOCAL) ondemand_local,
    max(LOBANALYTICS2_usd) epm_usd,
    max(LOBDATAINTEGRATION2_usd) eim_usd,
    max(IDD_AMOUNT_usd) idd_usd,
    max(ONDEMAND_AMOUNT_usd) ondemand_usd
    FROM edw.sales_consulting_activity_fct t1 ,
    select
    o.oppty_id_number,
    o.oppty_id,
    O.OPPORTUNITY_KEY,
    LICENSE_USD LICENSE_USD ,
    LICENSE_LOCAL LICENSE_LOCAL,
    o.FYM_USD maintAINANCE_usd,
    o.FYM_LOCAL maintAINANCE_LOCAL,
    o.TRAINING_USD training_usd,
    o.TRAINING_LOCAL training_LOCAL,
    o.CONSULTING_USD consulting_usd,
    o.CONSULTING_LOCAL consulting_LOCAL,
    o.RENEWAL_USD renewals_usd ,
    o.RENEWAL_local RENEWAL_local ,
    o.LOBANALYTICS2_LOCAL,
    o.LOBANALYTICS2_usd,
    o.LOBDATAINTEGRATION2_LOCAL,
    o.IDD_AMOUNT_LOCAL,
    o.ONDEMAND_AMOUNT_LOCAL,
    o.LOBDATAINTEGRATION2_usd,
    o.IDD_AMOUNT_usd,
    o.ONDEMAND_AMOUNT_usd
    from edw.opportunity_hist_fact o
    where o.SOURCE_SYSTEM='SFDC'
    and upper(status)='ACTIVE'
    and o.last_modified_date = (select max(last_modified_date )from edw.opportunity_hist_fact o2 where o.opportunity_key = o2.opportunity_key))T2,
    ( Select activity_key,OPPTY_ID_NUMBER, MIL.milestone_KEY,MIL.milestone_name oppty_milestone_name_hist,milestone_id
    oppty_milestone_id_hist, milestone_prob,start_date,oppty_close_date,end_date FROM
    EDW.opportunity_hist_fact OPP,
    edw.milestone MIL,
    edw.sales_consulting_activity_fct act WHERE
    ACTIVITY_DATE >=start_date (+) and activity_date <=opp.last_modified_date(+)
    and OPP.OPPTY_ID_NUMBER (+) =act.OPPTY_NUMBER
    and OPP.milestone_key =MIL.milestone_key(+) ) T3
    where t1.oppty_NUMBER (+) =T2.OPPTY_ID_NUMBER
    and t1.activity_key=t3.activity_key
    --and oppty_number ='279749'
    GROUP BY OPPTY_ID,
    oppty_number,
    OPPORTUNITY_KEY,
    SALES_CONSULTANT_HIST_KEY ,
    company_add_source_key,
    SALES_CONSULTANT_ID,
    SALES_EMPLOYEE_HIST_KEY,
    ACTIVITY_TYPE ,
    ACTIVITY_DATE ,
    LAST_MODIFIED_DATE,
    CUSTOMER_FLAG,
    milestone_KEY,
    oppty_milestone_name_hist,
    oppty_milestone_id_hist,
    milestone_prob,
    start_date,
    oppty_close_date,
    end_date;
    Regards,
    Prem

  • Select query in materialized view with two dblinks

    Hi All,
    We have oracle 10g On windows.
    We are trying to create materialized view. Scenario is we have base table on other database and we are creating mview on different database.
    Basa database have two schema's and i am selecting records from that two schema's using two private db links.
    But when i am tryin gto create mview its not getting created. After 15 hrs. its still showing creation command and not finished.
    Query is :-
    Is it good practice to have two db links in select query of materialized view.

    Billy  Verreynne  wrote:
    Chanchal Wankhade wrote:
    Is it good practice to have two db links in select query of materialized view.Same db link being used twice, or two different db links?
    If the former, you ideally want the local Oracle db to send the join to the remote database, and for the remote database to drive the join between those 2 tables. There is a hint (<i>driving_site</i>) that can be used - or the join query can be defined on the remote database as a view, and the local materialised view can then use that remote view.
    If you have 2 different db links and joining across these - usually a bad idea to perform distributed database joins. There are lots of limitations as to how the tables can be joined. Worse case, full table scans of both remote tables, pulling all the rows from the 2 remote database tables to the local database, and joining these on the local database.
    I have seen some severe performance issues in the past as a result of distributed joins. I'll rather use 2 materialised views for pulling both distributed tables's data locally, and then do the join on local data (using indexes, partition pruning, etc)Hi Billy,
    My scenario is i have two database database A and database B. Database A is having two schema's SCOTT AND HR. SCOTT schema have select privileges on HR schema.
    DB LINK is between Database B to Database A. name is db.link.B.A.oracle.com.
    What if i priovide while creating materialized view, the schema name before the table name in database B for this particuler table so it will pick up the table from that schema using same DB LINK(db.link.B.A.oracle.com.) that i am using to fetch records from SCOTT schema.
    Above schnario is like two base schema's and one db link using two schema.

  • Leave a distinct value in a materialized view on two tables

    Hi and thank you for reading,
    I have the following problem. I am creating a materialized view out of two tables, with "where a.id = b.id".
    The resulting materialized view list several values twice. For example, one customer name has several contact details and thus the customer name is listed several times. Now I would like to join each customer name with just ONE contact detail, how can I do that? (Even if I would loose some information while doing this).
    Thanks
    Evgeny

    Hi,
    You can do this
    SELECT   deptno, empno, ename, job, mgr, hiredate, sal, comm
        FROM emp_test
    ORDER BY deptno;
        DEPTNO      EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM
            10       7782 CLARK      MANAGER         7839 1981-06-09       2450          
            10       7839 KING       PRESIDENT            1981-11-17       5000          0
            10       7934 MILLER     CLERK           7782 1982-01-23       1300          
            20       7566 JONES      MANAGER         7839 1981-04-02       2975          
            20       7902 FORD       ANALYST         7566 1981-12-03       3000          
            20       7876 ADAMS      CLERK           7788 1987-05-23       1100          
            20       7369 SMITH      CLERK           7902 1980-12-17        800          
            20       7788 SCOTT      ANALYST         7566 1987-04-19       3000          
            30       7521 WARD       SALESMAN        7698 1981-02-22       1250        500
            30       7844 TURNER     SALESMAN        7698 1981-09-08       1500          
            30       7499 ALLEN      SALESMAN        7698 1981-02-20       1600        300
            30       7900 JAMES      CLERK           7698 1981-12-03        950          
            30       7698 BLAKE      MANAGER         7839 1981-05-01       2850          
            30       7654 MARTIN     SALESMAN        7698 1981-09-28       1250       1400
    14 rows selected.
    SELECT CASE
              WHEN ROW_NUMBER () OVER (PARTITION BY deptno ORDER BY empno) =
                                                                         1
                 THEN deptno
           END deptno,
           empno, ename, job, mgr, hiredate, sal, comm
      FROM emp_test;
        DEPTNO      EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM
            10       7782 CLARK      MANAGER         7839 1981-06-09       2450          
                     7839 KING       PRESIDENT            1981-11-17       5000          0
                     7934 MILLER     CLERK           7782 1982-01-23       1300          
            20       7369 SMITH      CLERK           7902 1980-12-17        800          
                     7566 JONES      MANAGER         7839 1981-04-02       2975          
                     7788 SCOTT      ANALYST         7566 1987-04-19       3000          
                     7876 ADAMS      CLERK           7788 1987-05-23       1100          
                     7902 FORD       ANALYST         7566 1981-12-03       3000          
            30       7499 ALLEN      SALESMAN        7698 1981-02-20       1600        300
                     7521 WARD       SALESMAN        7698 1981-02-22       1250        500
                     7654 MARTIN     SALESMAN        7698 1981-09-28       1250       1400
                     7698 BLAKE      MANAGER         7839 1981-05-01       2850          
                     7844 TURNER     SALESMAN        7698 1981-09-08       1500          
                     7900 JAMES      CLERK           7698 1981-12-03        950          
    14 rows selected.Edited by: Salim Chelabi on 2009-09-14 08:13

  • Use of db sequence in a materialized view

    Hi,
    Will it be possible to use a database sequence in a materialized view?
    The materialized view is to return the result set of query that joins multiple tables. One of the columns in the result set - the to-be-created materialized view - is null and requires a sequence.
    Will it be possible to include a db sequence in the query?
    Example:
    create materialized view example_mview
    as
    select example_sequence.nextval, table1.'*', table2.'*'
    from example_table1 table1, example_table2 table2
    where table1.id=table2.id

    What is the purpose of such numbering? To number each row?
    If so - then use ROWNUM as 1st column.
    SQL>with ddd
           as
           (select 333 COL from dual union all select 5444 COL from dual)
           select rownum,COL from ddd;ROWNUM COL
    1 333
    2 5444

  • Sdo_cs.transform procedure in a materialized view

    Hi all,
    Oracle version :10.2.0.4
    I am trying to do perform reprojection in a materialised view ( refresh on demand, complete mode).
    It seems everytime I refresh the MV ,this error pops up.
    SQL> exec dbms_mview.refresh('SUPER', 'C');
    BEGIN dbms_mview.refresh('SUPER', 'C'); END;
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-06531: Reference to uninitialized collection
    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
    <code>
    CREATE MATERIALIZED VIEW "SUPER" 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 "DATA_DATA" BUILD DEFERRED USING INDEX REFRESH COMPLETE ON DEMAND USING DEFAULT LOCAL ROLLBACK SEGMENT DISABLE QUERY REWRITE
    AS
    SELECT seq_nextval AS PID,
    SITE,
    STATE,
    reproject(geoloc)
    FROM BJON;
    <code>
    The procedure of reproject
    create or replace
    FUNCTION "REPROJECT" (p_coordinates in SDO_GEOMETRY)
         return SDO_GEOMETRY deterministic
         as v_coordinates SDO_GEOMETRY;
         BEGIN
              v_coordinates := sdo_cs.transform (p_coordinates, 4326);
              RETURN v_coordinates;
         end REPROJECT;
    Can anyone let me know hw I can put plug thereprojection in a materialized view.
    Edited by: CrackerJack on May 2, 2012 11:00 PM

    Hi all,
    Any clues?
    I have died of anymore ideas to make this work.
    All I need is a updated table with
    Primary key ,
    GEOMETRY 4326
    spatial index.
    metadata
    Teh materialized view is perfect except I can't do the reprojections.
    ORA-06531: Reference to uninitialized collection means have some null values in the array , but if you remove the Reproject function and just geometry itself , the materialised view works brilliant.
    I tried converting to 0,0 point in the function to tackle the nulls in array if any.. but doesn't work.
    sdo_cs.transform(nvl(geoloc, mdsys.sdo_geometry(2001, 8307, mdsys.sdo_point_type(0,0,NULL),NULL,NULL)),82027).get_wkt()
    Any ideas is much appreciated.
    Edited by: CrackerJack on May 6, 2012 10:27 PM

Maybe you are looking for

  • Windows 8 stops printer spooler in vista pc

    My AIO HP F4280 printer spooler service in my Windows Vista PC stops when I send a print job via wireless from my Windows 8 laptop PC. I downloaded and installed the Windows 8 software for the F4280 and if the printer is connected to the Windows 8 PC

  • Error in Block step in BPM.

    Hi all, I am getting the error in block step, my design follows like this i defined one transformation before block step, the transformation step will splits the input bunch of records into equal no of record packets and sent to block step.. while de

  • Itunes keeps not downloading with a file error

    A file error keeps popping up so I cant download itunes

  • Export leads to Excel

    Hello, You guys are like a God send!! Gotta keep digging for info - so here goes. I want to export leads into Excel for the purposes of creating a mailing. We get leads/inquiries which are entered into B1 - periodically they want to send a mailing to

  • HD Capacity Issues??!! HELP PLEASE!

    Macbook Pro Users, I'm very confused on why my HD is completely full!  As you can imagine i can't do anything since my startup disk is full. The only big item on my HD that i keep is my iPhoto library which totals 56 GB...When I look at the breakdown