WITH THE HELP OF SEPARATE OR ONE GROUP WHEN IN PRIMARY KEY CLAUSE

I WANT A WAY TO EFFECTIVELY PERFORM AGGREGATE FUNCTIONS ON A PARTNER OF THE PARENT TABLE CHILD TABLE AND RETURN ALL THE COLUMNS IN THE PARENT TABLE AND CALCULATED FROM THE CHILD TABLE COLUMNS.

THE PROBLEM IS THAT WHEN I USE GROUP BY ON ALL FIELDS IN THE PARENT, INCLUDING THE PARENT TABLE TABLE, I THINK THAT ORACLE TESTS ALL THE COLUMNS IN THE GROUP BY CLAUSE WHEN IT SHOULD GO HAS THE PRIMARY KEY MAKES ALL IMPLICITLY SEPARATE LINES.

I CREATED TWO TEST TABLES AND RRAN SOME QUERIES TO TEST AT THE SAME TIME.

HERE ARE THE TABLES:

CREATE TABLE A_PARENT_TABLES
(ACTIVATE THE NUMBER PT_PARENT_TABLE_ID (20.0) NOT NULL,)
PT_GRP_FEILD1 NUMBER (20.0) NOT NULL ACTIVATE.
PT_GRP_FEILD2 NUMBER (20.0) NOT NULL ACTIVATE.
PT_GRP_FEILD3 NUMBER (20.0) NOT NULL ACTIVATE.
PT_GRP_FEILD4 NUMBER (20.0) NOT NULL ACTIVATE.
PT_GRP_FEILD5 NUMBER (20.0) NOT NULL ACTIVATE.
PT_GRP_FEILD6 NUMBER (20.0) NOT NULL ACTIVATE.
PT_GRP_FEILD7 NUMBER (20.0) NOT NULL ACTIVATE.
PT_GRP_FEILD8 NUMBER (20.0) NOT NULL ACTIVATE.
PT_GRP_FEILD9 NUMBER (20.0) NOT NULL ACTIVATE.
ENABLE CONSTRAINT A_PARENT_TABLES_PK PRIMARY KEY (PT_PARENT_TABLE_ID)
);

CREATE TABLE A_CHILD_TABLES
(ACTIVATE THE NUMBER CT_CHILD_TABLE_ID (20.0) NOT NULL,)
CT_PARENT_TABLE NUMBER (20.0) NOT NULL ACTIVATE.
CT_VALUE_TO_SUM NUMBER (20.0) NOT NULL ACTIVATE.
ACTIVATE THE CONSTRAINT A_CHILD_TABLES_PK PRIMARY KEY (CT_CHILD_TABLE_ID)
CONSTRAINT CT_PARENT_TABLE_FK FOREIGN KEY (CT_PARENT_TABLE)
REFERENCES A_PARENT_TABLES (PT_PARENT_TABLE_ID) ON DELETE CASCADE ALLOW
);


I HAVE INSERTED THEN 20,000 RECORDS IN THE A_PARENT_TABLES TABLE AND 60,000 IN A_CHILD_TABLES (3 FOR EACH PARENT)
I THEN RAN THE FOLLOWING QUERY:


-ALL FIELDS GROUGPED
SELECT
PT_PARENT_TABLE_ID,
PT_GRP_FEILD1,
PT_GRP_FEILD2,
PT_GRP_FEILD3,
PT_GRP_FEILD4,
PT_GRP_FEILD5,
PT_GRP_FEILD6,
PT_GRP_FEILD7,
PT_GRP_FEILD8,
PT_GRP_FEILD9,
SUM (CT_VALUE_TO_SUM) AS SUMED_VALUES
Of
A_PARENT_TABLES,
A_CHILD_TABLES
WHERE
PT_PARENT_TABLE_ID = CT_PARENT_TABLE;

GROUP BY
PT_PARENT_TABLE_ID,
PT_GRP_FEILD1,
PT_GRP_FEILD2,
PT_GRP_FEILD3,
PT_GRP_FEILD4,
PT_GRP_FEILD5,
PT_GRP_FEILD6,
PT_GRP_FEILD7,
PT_GRP_FEILD8,
PT_GRP_FEILD9;


At TOOK 2.42 seconds set IN ŒUVRE



-ONLY GROUPED FIELDS
SELECT
PT_PARENT_TABLE_ID,
SUM (CT_VALUE_TO_SUM) AS SUMED_VALUES
Of
A_PARENT_TABLES,
A_CHILD_TABLES
WHERE
PT_PARENT_TABLE_ID = CT_PARENT_TABLE
GROUP BY
PT_PARENT_TABLE_ID;


At TOOK 0.71 seconds set IN ŒUVRE


WHY DOESN'T THE FIRST QUERY ARE REALIZING THAT HAVING PT_PARENT_TABLE_ID (PRIMARY KEY) IN THE GROUP BY CLAUSE MEANS THAT NO OTHER COLUMNS SHOULD BE CHECKED?

HOW CAN I ACHIEVE THE EQUVILENT OF THE FIRST QUERY IN A WAY MORE EFFECTIVE?

Hello

As you can see on the plain explain command
This full table scan done query1 on A_PARENT_TABLES
query2 done index range scan on A_PARENT_TABLES

This is one of the reasons why query2 runs faster than the application 1.

Why complete analysis of table to query1?
Its because you want in query1 to display other fields present in A_PARENT_TABLES and is not present in the primary index of this table, that is why he must go to the table for the data.

Hope this helps.
Concerning
Anurag Tibrewal.

Tags: Database

Similar Questions

  • With the help of CONSUME_CLICK called fieldChanged automatically when setFocus() is called in ButtonField

    Hi all.

    I posted this question before in http://supportforums.blackberry.com/t5/Java-Development/how-to-prevent-occurrence-menu-when-click-a-... but as a thread how on an issue different from the original. Given this is not connected somehow and a problem in itself, I decided to start a new thread. Forgive me if I'm wrong. I'll appreciate a response in one of the two sons

    I have a button that poped a menu when you click on it and going through the forums I found the solution of CONSUME_CLICK style. In fact, the menu popup more but it gave me an undesirable side effect

    Now, it happens that when I put the focus programmatically withbutton.setFocus (, the tracks of methodFieldChangeListener.fieldChange automatically producing unexpected click

    I tried to read the context value, but it is always zero

    How to avoid the popup menu AND the automatic one click when button.setFocus () is called

    I've seen this behavior in my Curve 8520 with v.5.0.0.1036. Simulators v.6.0 as 9300 and 9800 running don't behave this way. They do not have the auto click

    What happens if you just remove the earpiece of change of field (by calling setChangeListener (null)) before you call setFocus() and place it back after that called setFocus?

  • With the help of VM Workstation 8. error when restoring from instant snapshots are not allowed on this virtual machine.

    Hello

    I have takena instant and then try to turn on the machine and get a message:
    "Snapshots are not allowed on this virtual machine!

    When I try to start the snapshot form, I get an error:
    "snapshot restore error, snapshots are not allowed on this virtual machine.

    Can you please help?

    It seems that the configuration (.vmx) file has been deleted (zero byte). I recreated a new you have attached log files. Please replace the file corrupted with VMware Workstation (or at least tab of the virtual machine) closed in order to ensure that the replaced file gets read.

    André

  • Problem with the help of PS on Surface 3 when I attach a HDMI monitor

    PS works fine on my 3 surface. When I attach a HDMI monitor and drag the window of PS to him changes in scale and menus, panels etc. become huge as if I use a monitor very low resolution. Tried to change Windows settings for the size of the characters, but no difference. In this way, it is unusable

    Your surface 3 pro has a 12 "screen that displays 2160 x 1440 pixels and resolution from 216 DPI.  What is your HDMI monitor and pixel how does view it is more likely is a low resolution screen. And if you use CC 2014 2 x UI the image on the screen of Surface 3 pro is used as it has a 108 DPI, image resolution is like its on a screen is 1080x720PX Photoshop double pixel size her two times wider and twice as high.  4 native pixels of Surface 3 pro serve that would be as true on your HDMI display if it has a resolution of 100 dpi, it would be use as it has a resolution of 50DPI.  The image would look huge and and the display would only display 1/4 the amount of information it could display.  Do not use 2xUI...------using Photoshop CC 2014 on a tablet of Windows without a keyboard and a mouse

  • I just got a new modem (Arris SB6190) and now my Airport Extreme does not connect.  It worked fine with the previous modem (a rented one TWC).  Help!

    I just got a new modem (Arris SB6190) and now my Airport Extreme does not connect.  It worked fine with the previous modem (a rented one TWC).  Help!

    Always recommended to reset the airport back to settings by default and then set up again whenever you have a new modem or change your Internet Service provider.

    Turn off the new modem for at least 30 minutes. More is better.

    Perform a hard reset on the AirPort Extreme, then it turned off.

    Make sure that the Ethernet cable connects the modem to the "O" on the AirPort Extreme WAN port

    After the power of the modem 30 minutes down, turn on the modem and let it run for at least 5 minutes by itself.

    Then, turn on the airport and let it run a few minutes

    Set up AirPort Extreme again

    Important note... There are many reports of problems with the modem Arris SB and airports. Both are great products, but they do seem to work perfectly together for some users.

  • With the help of several types of video files into one film will prevent the publication?

    I am using Movie Maker on Vista.  I have mpeg, avi and wmv files.  The Movie Maker plays very well in project mode, but will not be published.  Multiple file extensions would be the source of trouble?

    If so, is there a quick fix?

    Hi d1bon,
     
    1. what exactly happens when you try to publish a project?
    2. do you get an error message?
     
    With the help of several file extensions should not be a concern.

    Disable video filters and check the result.
    1. click on tools and then click Options.
    2. click on the Compatibility tab.
    3. to turn off a filter, clear the check box next to the name of the video filter.

    You also uninstall the Codecs and check the result: Uninstall

    Please provide us with more details on the issue, so that we can better help you.
     
    Check publish a movie in Windows Movie Maker
    Check, solving problems with publishing a movie to your computer 
     
    Kind regards
    Syed
    Answers from Microsoft supports the engineer.

  • Insert the record of one table to another with the help of the cursor

    Help, please!

    the tables are - 1. countries (country_id pk, country_name, region_id)
    2A (country_id, country_name, region_id)
    table data are
    1 to 1
    2 b 2
    3 C 3
    NULL d 4
    5 e 5
    6 f 6
    7 g 7
    -----------------------
    Insert the record in the table a country table with the help of the cursor, insert all the non-null records.
    This procedure does not correct result
    -----------------------

    create or replace
    Amit procedure as
    cursor c1 is select * from a;
    RW a % rowtype;
    Start
    Open c1;
    Fetch c1 into rw.
    While (C1% found)
    loop
    insert into countries values (rw.country_id, rw.country_name, rw.region_id);
    commit;
    Fetch c1 into rw.
    If rw.country_id is null then
    Fetch c1 into rw.
    end if;
    end loop;
    Close c1;
    exception
    while others then
    dbms_output.put_line ('exception = name ' |) RW.country_name);
    end;

    You don't need cursor at all;

    create or replace procedure amit as
    
    begin
      insert into countries (Country_ID, Country_Name, Region_ID)
      (select a.Country_ID
             ,a.Country_Name
             ,a.Region_ID
       from a
      );
    
      dbms_output.put_line('Rows inserted : ' || sql%rowcount);
    
      commit;
    
    end;
    /
    
  • With the help of Club running on the Nike watch +.

    Hello

    This is something I have tried to work for a while and have not yet been able to find an answer. At the moment I use Nike + management club on my iPhone to follow the tracks that I find that gps is better than just using the application of the workout on my watch. However, something that really bothers me is that I start the race on my phone, but I can't then view my stats while running without having to press on and tap the watch and wait for the application to load, very irritating to race. I want to be able to lift my wrist and live stats are there to watch me, not listening and not get my phone out of my pocket. Surely this is something that can make the original watch?

    As a separate issue with the new app, Nike +, it does not recognize the songs I downloaded on my phone of Apple music in my playlists, then I have to play the separatelay of music through the application of music as opposed to go with Nike +? The ides on how to fix or is this a known problem with the latest Nike + app?

    Hello

    You may find it useful to consult the support resources of Nike and/or contact Nike for assistance with the help of their application:

    More information:

    https://iTunes.Apple.com/us/app/Nike+-run-Club/id387771637?Mt=8

  • ow change titles & dates of lots of pictures (like in iPhoto?) With the help of Mac 'Pages' on, 2008 aluminium MacBook running OSX El Capitan 10.11.4

    How to change titles & dates of lots of pictures (like in iPhoto?) With the help of Mac 'Pages' on, 2008 aluminium MacBook running OSX El Capitan 10.11.4

    With the help of Mac 'Pages '.

    A typing mistake?

    If it is and you mean Photos Date of Mac are modified by selecting the photos using the Image menu == > adjust the time and date of order and changes made to the metadata such as keywords, location, etc. are made by selecting the photos and find the info and registering metadata in the Info window

    These are detailed in the help topics of pictures - a good place to look for help on the Photos

    View and add information about the photos

    You can view and add information about your photos. For example, you can see the date and time a photo was taken, the information about the camera that took the photo and badges that indicate the status of the photo. You can assign titles and captions to photos, add or change the location of the photos and change the date and time for them information. You can select multiple photos in an instant and add or change information about them all at once.

    Open pictures for me

    View and add information about the photos

    To view or change information for the photos, you select one or more photos, and then open the information window.

    • Open the Info window: Double-click a photo to view it, and then click the Info button in the toolbar or press on command I.
    • Add or change information: Change the following.
      • Title: Enter a name in the title field.
      • Description: In the Description field, type a caption.
      • Favorite: Click the Favorites button to mark the photo as a favorite. Click the button again to deselect.
      • Keywords: Enter the keywords in the keywords field. When you type, Photos suggest keywords that you have used before. Press enter when you have finished a keyword. To remove a keyword, select it and press DELETE.
      • Faces: Click on and type a name to identify a face. Click on several times, and then drag the identifier of the face different faces to identify many faces in a photo.
      • Location: Enter a location in the location field. When you type, Photos suggest places you can choose. To change a location, you can search a different location or change the location by dragging a PIN on the map. To remove location information, delete it or choose Image > location, then choose Remove location or back to the original location. You cannot assign a location if your computer is not connected to the Internet.

    Show titles, other metadata and badges

    Change the date and time of photo

    You can change the date and time associated with a picture. You can do this if you are traveling to a location in another time zone, and your camera affect your dates photos and periods that are correct for your House, but not the place you visited.

    1. Select the photos you want to edit.
    2. Choose Image > adjust Date and time.
    3. Enter the date and time you want in the modified field.
    4. Click a time zone on the map, if necessary.
    5. Click on adjust.
  • Help? With the help of file system Ext3 on key USB on Linux RT target

    We have been affected by problems with the SD cards and USB drives formatted in FAT32 on some devices, according to Linus RT of long-term monitoring (mainly the cRIO-9035). It seems that readers are vulnerable to fluctuations in current and unexpected reboots (which are inevitable on these sites). Write aborted operations make the damaged discs, thus sabotaging logging after reboot.

    We have identified two solutions; implement both gives the best redundancy:

    (1) installation of UPS (uninterrupted power supply for emergency supplies/batteries) - done

    (2) using the file system apparently more robust 'ext3', which is available on the target RT Linux (FAT32, ext2 and ext3) - don't have not so far:

    ->, I was not able to properly format a USB stick for ext3. I use the MiniTools Partition Manager and don't get any errors when create and format partitions. But they appear as 'read only' when it is inserted into the chassis of the RT. All attempts to access it, other than to observe the empty folder sdxx in ' / media "is returning errors.

    Someone had a bit of luck with the help of ext3 disks formatted as data drives on the objectives of the RT Linux? It is worthwhile to solve my problems or should I use FAT32 and the observed risk?

    I do not consider this but a temporary solution:

    I ran into issues when you use MiniTools Partition Wizard to partition and format my thumb on Win10 records. An unidentified change makes the inaccessible disks and freeze the browsing of file on the PC when I try to delete the partition. It was quite annoying!

    I decided to try another partition tool and went for the EaseUs Partition Master (free version for the moment). I formatted successfully one of the troublesome discs with it (to add some uncertainty to the solution, I used another brand sp * banking, new PC to do). The reader now mounted in read-write and allows the startup application create the I want to store files in folders.

    I'm very curious to know the difference between the tools of both partitions and their formatting...

  • With the help of modulated signal pulse width (square wave) to control when a signal is enabled or disable

    With the help of modulated signal pulse width (square wave) to control when a signal is enabled or disable

    Hello all

    I am using a modulated signal to labview created pulse width (square wave) to control when a signal is activated or not.

    Here is my logic and a concrete example:
    (1) the wave source signal is continuous
    (2) use a PWM (square wave) created in labview to control when the signal is enabled or disabled
    (3) if the PWM (amplitude) signal is superior to 0 play signal PWM is not greater than 0 do not play signal.

    I use actually this to the sequence step / pulse several distinct magnetic coils using my audio card (which has several channels of audio output), I have a signal in labview played constantly.  As to compare it to the PWM (square wave) which controls whether or not the signal is played on each separate channel.  That way I can control which coil is on and offshore and in what order they are activated.

    I couldn't find an edge detection for a square wave created in labview, so I tried the limits, but it doesn't seem to work unless I change the phase manually and it only goes 1-1.  I'm just trying to compare the PWM (edges of the square wave) already created by labview / play a signal if the pulse is greater than 0 and it shuts off the signal, if she is less than 0.

    Should I do this another way

    TIA

    A waveform contains an array of values. You must check every value and respond accordingly:

  • With the help of semaphore with a Global Variable - correct use?

    Hi all

    I looked in the use of global variables and in my case, it seemed with the help of a semaphore is the appropriate solution.

    In my case, I use a global variable to store the State of the system. Asynchronous two with screw environment (same VI) will follow two COM ports to see if they get a ' login:' command prompt. If the COM port is associated with Alpha, Charlie, or Echo, it increments by 1, and if it is associated with the Bravo, Delta, or Foxtrot, is incremented by 2 GV. If the GV is 3, the rest of the code will run. In this case, it must be a port COM A, C or E; the other should be B, D or F.

    A VI parent is called inside a loop. He works for the first loop. He never adds up to 3 on the second loop, however. I can't understand why. Please let me know if my code is a poor use of semaphores, or if there is debugging I can try.

    I'm still relatively new to LV, so I'm sorry if my screws are difficult to read. I created this in LV2011.

    Thanks for any help!

    CelerityEDS wrote:

    The output of my time looping (wait GV = 3) goes to the structure of the case on the bottom right (clear SGS, PasswordEntry, etc.), so the GV get indeed consulted by the upper case structure right.

    ??

    Your right upper case structure does not run until your time ends in a loop.  The while loop does not stop until the total is equal to 3.  Where can increment you the world besides structures case you cannot yet?

    Have you tried in your point culminating execution of the VI in order to see how they are actually running?

    Another problem that I see.  Assuming that your first while the loop is going to end.  In the structures of your case, you lock the semaphore.  But you can never unlock the semaphore unless you have the right combination of conditions that allow you to get to the case that unlocks the semaphore.  The conditions are based on data that are read before the start of the case of structure, which means that data will not be read and changed until it all ends.  You have the timeout of your lock semaphore connected on one of the cases, but your semaphore lock can never timeout because you do not have a value on his entry time-out.  I think you have a situation where you can lock a semaphore, then arrive at a situation where you can not unlock, then wind locking up of your cold code.

    I don't really think that you need a semaphore at all.  I think you can protect reading and writing functional your overall using a global variable, i.e. the motor action.  Overall, I think you need to rethink the architecture of your code.

  • With the help of JavaScript condition in the dynamic action of JQuery selector

    Hi guys,.

    I have a Setup master detail on a page.

    The detail section, I have a tabular presentation.  One of the fields is a selection list.  The first record in the select contains the value * not * that has a value of primary key for the 1.  I have a distinct region with a simple text field where the user can insert a value into the table if the value does not exist.

    I want than the region of text element to only appear if the value * not listed * is selected.

    I managed to make it work when the value is selected with the help of dynamic action with a bit of JQuery and JavaScript by setting the ID on the selection list to 'create' and have the following in JavaScript $(this.triggeringElement) .val ()! = 1 in the JavaScript for dynamic action condition shows it or hides the region of 'create' and that works well.

    However, if the secondary table is empty before the detail records were created (nothing selected in triggering jQuery Selector) the region of create is displayed when I don't want it.

    I guess I need some sort of NVL in JavaScript condition?

    I use APEX v4.2.

    Any advice would be appreciated.

    Chris

    Cashy wrote:

    I have a Setup master detail on a page.

    The detail section, I have a tabular presentation.  One of the fields is a selection list.  The first record in the select contains the value * not * that has a value of primary key for the 1.  I have a distinct region with a simple text field where the user can insert a value into the table if the value does not exist.

    I want than the region of text element to only appear if the value * not listed * is selected.

    I managed to make it work when the value is selected with the help of dynamic action with a bit of JQuery and JavaScript by setting the ID on the selection list to 'create' and have the following in JavaScript $(this.triggeringElement) .val ()! = 1 in the JavaScript for dynamic action condition shows it or hides the region of 'create' and that works well.

    However, if the secondary table is empty before the detail records were created (nothing selected in triggering jQuery Selector) the region of create is displayed when I don't want it.

    I guess I need some sort of NVL in JavaScript condition?

    I use APEX v4.2.

    Simple solution is to hide the region containing the element of text by default, using the style = "" view: no ' in the property of the attributes of the area in the region. " It will be always hidden when the page initially, but its visibility will be controlled by the DA subsequently.

  • Hello, I accidentally opened an old file Ircat... and now can't figure out how to return to my only current.  With the help of Mac Yosemite, Lightroom CC

    Hello, I accidentally opened an old file Ircat... and now can't figure out how to return to my only current.  With the help of Mac Yosemite, Lightroom CC

    Thank you!

    File-> open recent. Lists the catalogs you have opened and will allow you to choose one of the previous catalogues.

  • dml execution 2 statements at a time with the help of execute immediate

    I would like to run 2 DML statements at a time with the help of execute immediate usefulness,.

    ex:

    update employee set ename = 'Chantal' where eno = 123;
    Update dept set dname = 'IT' where dno = 345;

    I want the two statement to execute at a time, but I don't want to use any loop as well.

    Thanks in advance

    You can use:

    execute immediate 'begin update employee set ename='jagadeesh' where eno=123; update dept set dname='IT' where dno=345; end;';
    

    Although updates will always run one after the other.

    If you want the simultaneous treatment, then you need to use DBMS_JOB and DBMS_SCHEDULER to plan both work to run to run each of the statements independently.

Maybe you are looking for

  • How can I prevent updates of Firefox on a computer I want to maintain 3.6.2.4 version?

    Using OS 10.5.8 and Firefox version 3.6.2.4. I use Global Transport (credit card processing program) they tell me only works with Internet Explorer. I used it successfully on several computers with Firefox for about 2 years, but in the last update fo

  • Apple's music is too boring to use

    Right; I wish I didn't have to write this, but Apple music got so frustrated in the 6 months that I used it, I have to. Why oh why is the feature of the music so terrible offline? I download music for offline use, to see that when I have no internet

  • Cannot print the portable dm4 Web page

    When you attempt to print from a Web page, everything that comes out is a page with "Page 1 of 1" at the top and in this down: file:///C:/Users/Susan/AppData/Local/Temp/Low/HZI6JA0J.htm with the date.  I have a Pavilion dm4 and Windows 7.  Thank you.

  • New Toshiba wireless turns off the Internet (by Linksys WRT110)

    I "ORDERED" a new Toshiba A660 (custom) yesterday. We have a DSL with Motorola modem and Cisco Linksys WRT110 router with a Cat5 connection.  For a brief period the Toshiba could access the Internet through the radio (I registered the computer and th

  • Display driver to disable hardware acceleration

    I just download "total screen recorder' and the first thing is it me to disable hardware acceleration. Went to the settings and tried to do it but I was told I could not turn it off. He made this statement;"Your current display driver does not allow