Query rewrite don't work wor aggregate query but work for join query

Dear experts,
Let me know what's wrong for
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
I have two MATERIALIZED VIEW:
A) -- Only join
CREATE MATERIALIZED VIEW "SCOTT"."TST_MV"
ENABLE QUERY REWRITE AS
SELECT "T57410"."MEMBER_KEY" "MEMBER_KEY",
"T57410"."ANCESTOR_KEY" "ANCESTOR_KEY",
"T57410"."DISTANCE" "DISTANCE",
"T57410"."IS_LEAF" "IS_LEAF",
"T57460"."DEPARTMENTID" "DEPARTMENTID",
"T57460"."NAME" "NAME","T57460"."PARENT"
"PARENT","T57460"."SHORTNAME" "SHORTNAME",
"T57460"."SKIMOID" "SKIMOID"
FROM "BI_OIV_HIER" "T57410",
"BI_DEPARTMENTS" "T57460"
WHERE "T57410"."ANCESTOR_KEY"="T57460"."DEPARTMENTID";
B) -- Join with aggregation
CREATE MATERIALIZED VIEW "SCOTT"."TST_MV2"
("C41", "C42", "C43",
"C44", "C45", "C46",
"C47", "C48", "C49",
"C50", "C51", "C52",
"C53", "C54", "C55",
"C56", "C57", "C58",
"C59", "C60", "C61",
"INCIDENTTYPE")
ENABLE QUERY REWRITE
AS SELECT COUNT(T56454.TOTAL) AS c41,
T56840.CATEGORYID AS c42,
T56840.PARENT AS c43,
T56908.DOCSTATEID AS c44,
T56908.PARENT AS c45,
T56947.EXPIREDID AS c46,
T56947.PARENT AS c47,
T56986.ISSUESTATEID AS c48,
T56986.PARENT AS c49,
T57025.LOCATIONID AS c50,
T57025.PARENT AS c51,
T57064.NEWID AS c52,
T57064.PARENT AS c53,
T57103.PARENT AS c54,
T57103.RESOLUTIONID AS c55,
T57142.PARENT AS c56,
T57142.RESPONSIBLEID AS c57,
T57181.PARENT AS c58,
T57181.SOURCEID AS c59,
T57460.DEPARTMENTID AS c60,
T57460.PARENT AS c61,
T56454.INCIDENTTYPE
FROM BI_OIV_HIER T57410
BI_DEPARTMENTS T57460
BI_SOURCE_HIER T57176
SOURCE T57181
BI_RESPONSIBLE_HIER T57137
RESPONSIBLE T57142
BI_RESOLUTIONS_HIER T57098
RESOLUTIONS T57103
BI_NEW_HIER T57059
NEW T57064
BI_LOCATIONS_HIER T57020
LOCATIONS T57025
BI_ISSUESTATES_HIER T56981
ISSUESTATES T56986
BI_EXPIRED_HIER T56942
EXPIRED T56947
BI_DOCSTATES_HIER T56903
DOCSTATES T56908
BI_CATEGORY_HIER T56835
CATEGORY T56840
INCIDENTS T56454
WHERE ( T56454.RESOLUTION = T57098.MEMBER_KEY
AND T56454.CATEGORY = T56835.MEMBER_KEY
AND T56454.DOCSTATE = T56903.MEMBER_KEY
AND T56454.EXPIRED = T56942.MEMBER_KEY
AND T56454.ISSUESTATE = T56981.MEMBER_KEY
AND T56454.LOCATION = T57020.MEMBER_KEY
AND T56454.NEW = T57059.MEMBER_KEY
AND T56454.RESPONSIBLE = T57137.MEMBER_KEY
AND T56454.SOURCE = T57176.MEMBER_KEY
AND T56454.DEPARTMENTID = T57410.MEMBER_KEY
AND T56835.ANCESTOR_KEY = T56840.CATEGORYID
AND T56903.ANCESTOR_KEY = T56908.DOCSTATEID
AND T56942.ANCESTOR_KEY = T56947.EXPIREDID
AND T56981.ANCESTOR_KEY = T56986.ISSUESTATEID
AND T57020.ANCESTOR_KEY = T57025.LOCATIONID
AND T57059.ANCESTOR_KEY = T57064.NEWID
AND T57098.ANCESTOR_KEY = T57103.RESOLUTIONID
AND T57137.ANCESTOR_KEY = T57142.RESPONSIBLEID
AND T57176.ANCESTOR_KEY = T57181.SOURCEID
AND T57410.ANCESTOR_KEY = T57460.DEPARTMENTID
GROUP BY T56840.CATEGORYID,
T56840.PARENT,
T56908.DOCSTATEID,
T56908.PARENT,
T56947.EXPIREDID,
T56947.PARENT,
T56986.ISSUESTATEID,
T56986.PARENT,
T57025.LOCATIONID,
T57025.PARENT,
T57064.NEWID,
T57064.PARENT,
T57103.PARENT,
T57103.RESOLUTIONID,
T57142.PARENT,
T57142.RESPONSIBLEID,
T57181.PARENT,
T57181.SOURCEID,
T57460.DEPARTMENTID,
T57460.PARENT,
T56454.INCIDENTTYPE;
So, optimizer uses query rewrite in
select * from TST_MV
and don't use query rewrite in
select * from TST_MV2
within one session.
select * from TST_MV should be read as underlying select for TST_MV:
SELECT "T57410"."MEMBER_KEY" "MEMBER_KEY",
"T57410"."ANCESTOR_KEY" "ANCESTOR_KEY",
"T57410"."DISTANCE" "DISTANCE",
"T57410"."IS_LEAF" "IS_LEAF",
"T57460"."DEPARTMENTID" "DEPARTMENTID",
"T57460"."NAME" "NAME","T57460"."PARENT"
"PARENT","T57460"."SHORTNAME" "SHORTNAME",
"T57460"."SKIMOID" "SKIMOID"
FROM "BI_OIV_HIER" "T57410",
"BI_DEPARTMENTS" "T57460"
WHERE "T57410"."ANCESTOR_KEY"="T57460"."DEPARTMENTID";
So, select * from TST_MV2 should be read by similar way as underlying select to TST_MV2
DBMS_STATS.GATHER_TABLE_STAT is done for each table and MV.
Please help to investigate the issue.
Why TST_MV2 don't used for query rewrite ?
Kind regards.

Hi Carlos
It looks like you have more than one question in your posting. Would I be right in saying that you have an issue with how long Discoverer takes when compared with SQL, and a second issue with regards to MVs not being used? I will add some comments on both. If one of these is not an issue please inform.
Issue 1:
Have you compared the explain plan from Discoverer with SQL? You may need to use a tool like TOAD to see it.
Also, is Discoverer doing anything complicated with the data after it comes back? By complicated I mean do you have a large number of Page Items and / or Group Sorted items? SQL wouldn't have this overhead you see.
Because SQL would create a table, have you tried creating a table in Discoverer and seeing how long it takes?
Finally, what version of the database are you using?
Issue 2:
Your initial statement was that query rewrite works with several MV but not with others, yet in the body of the report you only show explain plans that do use the MV. Could you therefore go into some more detail regarding this situation.
Best wishes
Michael

Similar Messages

  • HT204187 Email account does not work on the Mac but works on my iPad and iPhone. The account information was added on the Mac. I keeps rejecting my password.

    I have seral email accounts on my Mac. One does not work on the Mac but works on my iPad and iPhone. The account information was added on the Mac. I keeps rejecting my password.

    You don't input the information in manually for iCloud mail. It is automatically set up for you when you sign into iCloud via System Preferences and choose the Mail checkbox. Sign out of iCloud or deselect Mail in iCloud preferences. Open Mail's preferences and choose accounts tab. If iCloud account still exists in the list, delete it. Sign back into iCloud or check the box for mail. The account will be auto created for you.

  • Firefox has stopped working in Windows 7 but works in Windows safe mode

    I am sending this from a different computer on which Firefox works fine. My problem is on a Windows 7 PC -- in the past few days Firefox has stopped working in normal mode but works ok in Windows safe mode. I keep getting a Windows error message that it has stopped working and I will be notified if there is a solution. Of course, I am never notified. I have tried resetting Firefox when in Windows safe mode, as well as uninstalling and reinstalling Firefox, after having deleted all the program folders and appdate. I've exhausted every possible fix I could find in the Mozilla support forums but I still can's solve the problem. Can you help please?

    *3
    Sometimes a problem with Firefox may be a result of malware installed on your computer, that you may not be aware of.
    You can try these free programs to scan for malware, which work with your existing antivirus software:
    * [http://www.microsoft.com/security/scanner/default.aspx Microsoft Safety Scanner]
    * [http://www.malwarebytes.org/products/malwarebytes_free/ MalwareBytes' Anti-Malware]
    * [http://support.kaspersky.com/viruses/disinfection/5350 Anti-Rootkit Utility - TDSSKiller]
    * [http://general-changelog-team.fr/en/downloads/viewdownload/20-outils-de-xplode/2-adwcleaner AdwCleaner] (for more info, see this [http://www.bleepingcomputer.com/download/adwcleaner/ alternate AdwCleaner download page])
    * [http://www.surfright.nl/en/hitmanpro/ Hitman Pro]
    * [http://www.eset.com/us/online-scanner/ ESET Online Scanner]
    [http://windows.microsoft.com/MSE Microsoft Security Essentials] is a good permanent antivirus for Windows 7/Vista/XP if you don't already have one.
    Further information can be found in the [[Troubleshoot Firefox issues caused by malware]] article.
    Did this fix your problems? Please report back to us!

  • Why the preloader doesn't work in IE 8 but works in FireFox?

    Why the preloader doesn't work in IE 8 but works in FireFox?
    Please see the attached files.  Thanks in advance.

    Why doesn't the preloader work in IE8?
    What's "virtual sandbox"?

  • [svn:fx-trunk] 13257: Fix for @inheritDoc not working on a setter, but works on a getter

    Revision: 13257
    Revision: 13257
    Author:   [email protected]
    Date:     2010-01-04 10:49:13 -0800 (Mon, 04 Jan 2010)
    Log Message:
    Fix for @inheritDoc not working on a setter, but works on a getter
    QE notes: None.
    Doc notes: None
    Bugs: SDK-24727
    Reviewed By: Paul
    Tests run: checkintests
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24727
    Modified Paths:
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ClassTable.java

    steabert wrote:
    Hi,
    I had a similar problem with my Dell Latitude E4310, and apparently also the E6410, E6510.
    The solution for me was to add the following line to /etc/modprobe.d/modprobe.conf:
    options snd-hda-intel model=dell-s14
    I tried that, unfortunately it does not work with this chipset. I do get a different set of channels though but it still cannot record anything. Maybe this chipset is too "new" for alsa. The latest release dates back from the end of January. Support for it is explicitly stated in the changelog to 1.0.24 but perhaps the recording part of it slipped through the cracks. ALSA bug tracking system seems quite closed.

  • My outlook stopped working on my imac but works on iphone, can anyone help?

    Hi,
    My outlook stopped working on my imac but works on iphone, can anyone help?
    This seems to happen periodically.
    Thanks,
    Justin

    Sorry meant my Mail has stopped working on my iMac. It had large items in the Outbox from last weekend. I guess it just got its knickers in a twist as I deleted the large emails, containing video and now it is working again.
    Thanks for coming back to me tho. Appreciated.

  • Google drive does not work with specific group but works with all users group!!

    Hi,
    Why Google drive does not work with specific group but works with all users group?
    My rule :  Internal > external > all users = works fine
    But
                   Internal > external > A group = not working !!

    Hi,
    if you require user authentication in Firewall policy rules, the clients must bei Webproxy clients (for HTTP / HTTPS) or TMG clients (for TCP/UDP):
    http://technet.microsoft.com/en-us/library/bb794762.aspx
    regards Marc Grote aka Jens Baier - www.it-training-grote.de - www.forefront-tmg.de - www.galileocomputing.de/3276?GPP=MarcGrote

  • Javascript doesn't work on safari desktop but works properly on Safari  ipad. I already cleaned a cache without success

    javascript doesn't work on safari desktop but works properly on Safari  ipad. I already cleaned a cache without success. IE, FF and Opera are working well

    Try this  - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.)
     Cheers, Tom

  • HP ProBook 5220m Fan not working with battery power but work fine with adapter plugged in

    Hi,
    Any one have this issue?
    HP ProBook 5220m (Bios Version F50) Fan not working with battery power but work fine with adapter plugged in.
    This issue was found in my replacement motherboard. the original mother do not have this issue.
    The origianl mother to be replace is due to can't power on after a power failure recovery. I believe was due to power surge killed the motherboard's power controller circuitry.
    Appreciate any one can provide clue for resolving the problem.
    I have tried to install speedfan to try my luck, but it can't any fan in the application to configure. (Bios Version F50) 

    @wheng 
    ‎Thank you for using HP Support Forum. I have brought your issue to the appropriate team within HP. They will likely request information from you in order to look up your case details or product serial number. Please look for a private message from an identified HP contact. Additionally, keep in mind not to publicly post ( serial numbers and case details).
    If you are unfamiliar with the Forum's private messaging please click here to learn more.
    Thank you,
    Omar
    I Work for HP

  • My iPad speakers doesn't work whit some apps, but works ok with my iPod app. How can I fix it?

    My iPad speakers doesn't work with some apps, but works ok with my iPod app. The sounds from this apps works ok with earplugs. How can I fix it?

    Talking to yourself again ...eh?

  • Updatable ResultSet for join Query

    Hi all,
    It is inevitable that i use a 'JOIN' operation for a particular query and i need the resultSet to be updated. Heard JDBC driver doesnt support this. Is there any workaround for this. Any help is really appreciated.
    Thanks,
    Abhijit

    Welcome to the forum!
    >
    It is inevitable that i use a 'JOIN' operation for a particular query and i need the resultSet to be updated. Heard JDBC driver doesnt support this.
    >
    As gimbal2 mentioned this isn't supported even by the latest 11g version and driver. See 'Result Set Limitations' in Chapter 17 of the JDBC doc for confirmation and discussion.
    http://docs.oracle.com/cd/E14072_01/java.112/e10589/resltset.htm#BABBCECI
    >
    Result Set Limitations
    The following limitations are placed on queries for enhanced result sets. Failure to follow these guidelines will result in the JDBC driver choosing an alternative result set type or concurrency type.
    To produce an updatable result set:
    A query can select from only a single table and cannot contain any join operations.
    In addition, for inserts to be feasible, the query must select all non-nullable columns and all columns that do not have a default value.
    A query cannot use SELECT * .
    However, there is a workaround for this.
    A query must select table columns only.
    It cannot select derived columns or aggregates, such as the SUM or MAX of a set of columns.
    >
    >
    Actually my exact requirement is i have two tables, earlier i used to select the results from one table and check for the existance of the corresponding record in the second table from the output of resultset. This is causing a lot of performance issue and i thought of using a single query by joining two tables which reduces the number of records.
    >
    So is this a correct description of what you want to do?
    1. TableA and TableB have one or more columns in common.
    2. Query TableA, possibly using filter predicates (WHERE tabA.col1 ...) and identify records in TableB that match on the join columns
    3. Update the TableB records from step #2.
    If so then you have a couple of options.
    The record-by-record approach would be to execute your current query (the one that joins the two tables) but retrieve ONLY the ROWID from TableB. Then iterate thru the result set and use a separate query to get each TableB record by using the ROWID retrieved from the first query. This is different from your original approach because the first query WILL identify the TableB records you need it just won't retrieve them (only the ROWID).
    Your original performance issues were probably because you were retrieving ALL of the TableA records and then checking each one to see if there were any TableB records for it.
    The BULK approach would be a slight modification of of the record-by-record approach but pushes the work to the DB server.
    This approach queries TableB to retrieve ONLY those records that EXIST in the query of TableA just described. So the query is of the form
    SELECT * FROM TableB b WHERE EXISTS (SELECT '1' FROM TableA a WHERE a.col1 = b.col1);  This query only uses one table for the resultset and does not contain any join operators so it can be updateable.
    Test a simple query first until you get the syntax correct.

  • Custome Tcode is not working in QA system but working in DEV system

    Hello,
    We have copied QM11 tacode to ZQM11. We found this ZQM11 tcode is not working in QA system, but properly working in DEV system. When we are execute this tcode from QA system with all required input, it says
    "No objects could be selected that met your selection criteria."
    But when do it in DEV system it is working fine. I have done following steps to check error
    1) All authorizations are good
    2) I have compared E070 and E071 table to found transport done with proper way.
    3) I have checked SE93, tcode condition is good.
    4) SE97 -->found call transaction is QM11 for ZQM11
    5) From program code level Authority check maintained properly.
    AUTHORITY-CHECK OBJECT 'Q_QMEL'
                 ID 'QMART'    FIELD I_QMART
                 ID 'TCD'      FIELD I_TCODE
                 ID 'WERKS'    DUMMY.
    6) Performed authorization trace to found error agains object Q_QMEL (RC =4), but in the role Q_QMEL has define with it's  proper value supplied by our functional team.
    7) Shows all active object in SU24 against ZQM11 are good
    8) When we call tcode it has thrown the error agains Q_QMEL only
    I am not able to understand why does not work this tcode in QA system, although working in DEV is good.
    Please help me to resolve this issue
    Thanks
    Pavel

    Bieng declared $WERKS field as DUMMY, is not relevant, so no matter its value, it will pass..
    There's a catch! If even DUMMY means literally that no matter user has any value, he is still authorized but in reality for such \fields authorization check is only successful when a value ' ' or * is found in user's authorization else it errors out.
    Sorry confused with programs where AUTHORITY-CHECK has  ' ' coded instead of DUMMY. You are right, DUMMY specified for as field would pass authorization check with any/no value in user's authorization. Please ignore my statement
    Sandipan
    Edited by: Sandipan Choudhury on Dec 29, 2010 2:11 AM

  • AOL mail will not work on MacBook Pro, but works on iMac

    My wife has attempted to check her aol mail account online, through Safari, and every message that she opens appears as "garbage." I recently installed Snow Leopard on both of our computers. AOL mail works on my iMac, but not her Macbook Pro. Honestly, among other issues, I'm a little disappointed with Snow Leopard. Leopard was released without problems for either of us.

    Did you ever find out what the problem is???

  • Correct password doesn't work with Mail interface, but works with web interface.

    Mail claims "The POP server “mail.nykayak.com” rejected the password for user “valerie”, yet when I log in through the web interface the password works. All other accounts work. Has anyone experienced this and found a solution?

    Mackie, Welcome to the discussion area!
    On your iMac G3, go to the AirPort menu and select the network name. It will prompt you automatically for the correct type of wireless encryption password.
    I wouldn't trust selecting an option from Internet Connect.
    In AirPort Admin Utility, what type of wireless encryption have you enabled? If it is WPA2 the iMac G3 won't be able to connect.
    Also ensure that your AirPort Extreme base station (AEBS) is configured to work in an 802.11b compatible mode. The iMac G3 is only 802.11b.

  • HP Compaq NC8430 is not working on ANY battery, but works with AC adapter

    I have bought an used HP Compaq NC 8430.
    The computer fails to power on with its battery. But it's working with AC adapter.
    I blamed a bad battery but it cannot be that.
    I have switched the battery with a same model's one, which is 100% working.
    But the computer is not power on with the other battery. I have tried 2 more compatible batteries, still not working at all. Only working when connected with AC adapter. The yellow led lights, indicating the battery is being charged. But when unplugged from adapter, the PC is switching off instantly.
    It CANNOT be the battery, as all the batteries worked on a friend's NC8430 PC.
    It should be some kind of hardware fail?
    I have tried to flash the BIOS, to clean the battery contacts, to remove the battery drivers in the control panel... nothing worked.
    The HP battery check gives "No battery"
    Please, help

    "No battery" sounds more like a hardware issue (battery connector), i would suggest you to contact hp tech support (http://www8.hp.com/us/en/contact-hp/phone-assist.h​tml) on the same.

Maybe you are looking for

  • Why my RMI is not Working in Linux???

    Hiii how ru? I am Rahul here Well I have a problem that my RMI in not working on Linux.. so can u tell me the solution to my problem??? When i am typing following command i am getting exception as RmiNotBoundException java -Djava.security.policy=my.p

  • How to write a pdf?

    hello how do you write a pdf? is there a specification for writing it that i can just dump my info following that spec. into a file and thats that? is there a pdf package that i can use that already does this? i didnt see anything in the docs, but i

  • I would like to send a movie to a select few without having it open to the public. How do I do that?

    I made a movie that I would like to send to friends and family but not have it available to the public. Since Mobileme doesn't exist anymore, how do I do that? Thanks

  • Headache with button

    Hi, here is a link to FLA files www.fulek.com/bug/BUG_report.rar (This is another X-file's example, FLA's are actually empty but they have 2MB each when extracted). Short description of problem: StartFile.swf has one big button which is instance of B

  • How do i remove the top cover for the K410?

    I spilled water on the top of my computer, and it messed up one of the USB ports on the top of it...  now the computer constantly pops up connect/disconnect messages.  I want to take the top bezel (or cover, or whatever it's called) off so that i can