Need help in the optimization of the query with the Group and joins by clause

I'm having the problem by running the following query... It takes a lot of time. To simplify, I added the two tables FILE_STATUS = stores the file load details and COMM table Board table job showing records treated successfully and which was communicated to the other system real. Records with status = T is trasnmitted to another system and traansactions with P is waiting.
CREATE TABLE FILE_STATUS
(FILE_ID VARCHAR2(14),
FILE_NAME VARCHAR2(20),
CARR_CD VARCHAR2(5),
TOT_REC NUMBER,
TOT_SUCC NUMBER);

CREATE TABLE COMM
(SRC_FILE_ID VARCHAR2(14),
REC_ID NUMBER,
STATUS CHAR(1));

INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4);
INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0);

INSERT INTO COMM VALUES ('12345678', 1, 'T');
INSERT INTO COMM VALUES ('12345678', 3, 'T');
INSERT INTO COMM VALUES ('12345678', 4, 'P');
INSERT INTO COMM VALUES ('12345678', 5, 'P');
COMMIT;
Here's the query I wrote to give me the details of the file that has been loaded into the system. He reads the table of State and the commission files to display the name of the file, total records loaded, total at the table of the commission and the number of records which has finally been passed successfully loaded (Status = T) with other systems.
SELECT 
    FS.CARR_CD 
    ,FS.FILE_NAME 
    ,FS.FILE_ID
    ,FS.TOT_REC
    ,FS.TOT_SUCC
    ,NVL(C.TOT_TRANS, 0) TOT_TRANS
FROM FILE_STATUS FS
LEFT JOIN
(
    SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS
    FROM COMM
    WHERE STATUS = 'T'
    GROUP BY SRC_FILE_ID
) C ON C.SRC_FILE_ID = FS.FILE_ID
WHERE FILE_ID = '12345678';
In production, this request has several joins and takes a long time to deal with... the main culprit for me is the join on the COMM table to count the number of number of transactions sent. Please can you give me tips to optimize this query to get results faster? What I need to delete the Group and use the partition or something else. Help, please!

Don't know if it will be faster based on the information provided, but analytical functions offer an alternative approach;

select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans
  from (select fs.carr_cd,
               fs.file_name,
               fs.file_id,
               fs.tot_rec,
               fs.tot_succ,
               count(case
                        when c.status = 'T' then
                         1
                        else
                         null
                      end) over(partition by c.src_file_id) tot_trans,
               row_number() over(partition by c.src_file_id order by null) rn
          from file_status fs
          left join comm c
            on c.src_file_id = fs.file_id
         where file_id = '12345678')
 where rn = 1;

CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS
------- -------------------- -------------- ---------- ---------- ----------
LIBM    CM_LIBM.TXT          12345678                5          4          2

Tags: Database

Similar Questions

  • Need HELP! -The installer and excutable issues

    Hello

    I created a Labview installation program to install an executable file (.exe) on a clean machine, who has no any product of Labveiw, so the executable can run by itself without the evoriment of development. Given that the program needs to use sub - VI DAQmx so I include the engine runtime and DAQmx and everything that makes setup > 1.2 GB. At first everything went well.

    Now, we have to make some minor changes in the source code. My question is, what do I have to redo the installer every time for minor changes? I've seen the system creates several files when I build an executable:

    An .exe file

    A single file .aliases

    A configuration file

    A "Data" folder

    Can I just copy these files to a place so new version of the executable file can run without HAVING to build a new installer which exceeds 1 GB?

    Any help or suggestion is greatly appreciated!

    This is the same process as the regular creation of an installer.

    Way the easiest is probably to copy your existing full installer and then removed the additional installers of the copy and rename your copy as a hotfix.

    (i.e. make sure you just deselect the additional installers of the page indicated on the attached screenshot)

  • NEED HELP FOR THE RESOLUTION AND QUALITY?

    Hi guys

    I've done of these vector portraits type in photoshop for the past two weeks, we were all going well until, when someone sets up as a picture on facebook etc the quality is not as good as when I just display the image on my computer.

    I was from the new photoshop and using 800 x 800 pixels and the resolution to 72 pixels/inch, I wrong here somewhere? or is it the fact that I use photoshop to do this? im sure there are many people who will advise me to use illustrator, which I thought a lot to do. but I would like to know if this can be fixed in photoshop first.

    Thanks in advance for your help

    question.jpg

    It's a little pixel-ish in the areas...

    FAULTY zeth vector.jpg

    P.S. I also notice that it is working in the "defective" text box

    Once your support for a screen, you only need to worry about the pixel dimensions, the PPI is irrelevant. Facebook will tell you what's the resolution of each image. To my knowledge, Facebook does not support svg graphics in the opposite case, you could use Illustrator. Just make sure that when you don't create vector graphics in PhotoShop that you save a copy in a file buffer, as the jogging and png do not support vectors.

  • What is the difference between the Group and join?

    I understand what is the grouping of contacts. and I saw the impact of joinging contacts but why would I do that? He takes the contacts that join off the my list of good contacts individuals list is deleted and all that remains is the name of the principal that joined you.

    Why do this?

    If you have the same contact in more than one group of Gmail, the droid will join them together. This prevents duplicates appear in the contacts list.

  • NEED HELP IN THE GROUP BY CLAUSE CASES PLEASE

    User1983440 thanks for the help with the script below grouped by product category, can you or someone else help me group by another Case statement as well.


    WITH p AS)
    Select distinct
    partner, region, od. ORDER_AFFILIATE_NAME,
    Oh.external_order_number,
    Ain.get_g1 (queue_type) offers,
    Case
    When disp.category = 100 Then 'ORDER'
    When disp.category = 200 Then 'ACCESS'
    When disp.category = 300 Then 'DSL'
    When disp.category = 600 Then 'IPTV'
    "When disp.category = 700 Then'INTERNET"
    When disp.category = 800 Then 'VOIP'
    End up like product_category,
    To_char(OH.created_ts, 'yyyy-mm-dd HH24:mi:ss') CREATE_DATE
    -Case when ip.offer_type = "IPDSLAM" or instr (ip.display_name, "-d") > 0
    THEN 'IP - LAN'
    ELSE 'FTTN.
    end as product_type
    Case
    When disp.state = 4 and disp.state = 9 or disp.state = 21 or 22 = disp.state then 'cancelled '.
    When disp.state = 17 then "NRFC cancelled.
    When disp.state = 7 Then 'incomplete '.
    When disp.state = 3 or disp.state = 8, then "Finish".
    When disp.state = 6 or disp.state = 10 and disp.state = 13 or disp.state = 14 then 'pending - other ".
    When disp.state = 19 disp.state = 20 then "sent".
    When disp.state = 21 or disp.state = 22 then "Cancelled - CSUS.
    When disp.state = 23 or 24 = disp.state then 'Order Confirmation '.
    When disp.state = 1 or disp.state = 2 or disp.state = 15 then "receipt".
    Another 'other '.
    End as STATE_desc
    of AIN.impl_oh_order_header oh,.
    Ain.impl_order_data od,
    DISP AIN.sncr_order_curr_disp,
    AIN.impl_package ip
    where oh.created_ts between to_date ('2013-02-04', ' yyyy-mm-dd "")
    and to_date ('2013-02-11', ' yyyy-mm-dd "")
    and oh.order_type = 'COMMAND '.
    and disp.category to (200, 300, 600, 700, 800)
    and disp.state! = '5'
    and uscs = 0
    and disp.transaction_id = oh.transaction_id
    and od. transaction_id = oh.transaction_id
    and ip.transaction_id = oh.transaction_id
    and ip.package_type = 'PACKAGE '.
    and ip.parent_package_id is null
    and ip.product_type = 'COMMAND '.
    )
    SELECT product_category,
    COUNT (*)
    P
    GROUP BY product_category

    To summarize, by category of product, and then by state_desc:

    WITH p AS (
    Select distinct
    partner, region, od.ORDER_AFFILIATE_NAME,
    oh.external_order_number,
    ain.get_g1(queue_type) offer,
    Case
    When disp.category = 100 Then'ORDER'
    When disp.category = 200 Then'ACCESS'
    When disp.category = 300 Then'DSL'
    When disp.category = 600 Then'IPTV'
    When disp.category = 700 Then'INTERNET'
    When disp.category = 800 Then'VOIP'
    End as product_category,
    TO_CHAR(oh.created_ts, 'yyyy-mm-dd hh24:mi:ss') CREATE_DATE,
    Case when ip.offer_type = 'IPDSLAM' or instr(ip.display_name, '- D')> 0
    THEN 'IP-DSL'
    ELSE 'FTTN'
    end as product_type,
    Case
    When disp.state = 4 or disp.state = 9 or disp.state= 21 or disp.state= 22 Then 'Canceled'
    When disp.state = 17 Then 'Canceled NRFC'
    When disp.state = 7 Then 'Incomplete'
    When disp.state = 3 or disp.state = 8 Then 'Complete'
    When disp.state = 6 or disp.state = 10 or disp.state = 13 or disp.state =14 Then 'Pending - Other'
    When disp.state = 19 or disp.state = 20 Then 'Submitted'
    when disp.state = 21 or disp.state = 22 then 'Cancelled- CSUS'
    when disp.state =23 or disp.state = 24 then 'Order Confirmation'
    when disp.state =1 or disp.state = 2 or disp.state = 15 then 'Received'
    Else 'Other'
    End as STATE_desc
    from AIN.impl_oh_order_header oh,
    ain.impl_order_data od,
    AIN.sncr_order_curr_disp disp ,
    AIN.impl_package ip
    where oh.created_ts between to_date('2013-02-04', 'yyyy-mm-dd')
    and to_date('2013-02-11', 'yyyy-mm-dd')
    and oh.order_type = 'ORDER'
    and disp.category in (200, 300, 600, 700, 800)
    and disp.state !='5'
    and uscs= 0
    and disp.transaction_id = oh.transaction_id
    and od. transaction_id = oh.transaction_id
    and ip.transaction_id = oh.transaction_id
    and ip.package_type = 'PACKAGE'
    and ip.parent_package_id is null
    and ip.product_type = 'ORDER'
    )
    SELECT product_category, STATE_desc,
    COUNT(*)
    FROM p
    GROUP BY product_category, STATE_desc
    

    To summarize by state_desc, just remove "product category", the query above.

  • Help. I need help for the upgrade and the English Version for my Acer One Notebook

    I have an Acer One Notebook all in Japanese and to go to the English version and its still a product of windows 7. What kind of windows program should I update and do so as English version?

    Thank you

    Option 1: You have to upgrade your current edition to Windows 7 Ultimate.

    Option 2: You need to download and install the copy of English language of the current edition you have installed.

    Your options are very limited. I honestly would buy 10 Pro in Windows and install in English.

  • I NEED HELP Please im having a problem to forget my password and when I plug it it says its locked with a password he try to put the itunes thing but

    NEED HELP Please im having a problem to forget my password and when I plug it it says its locked with a password he tried to put the itunes thing but it says enter password I put in what I rember, then said lokced for five minutes help me pls

    Without knowing the password for your iPhone, there is no way to unlock it, bring even you to the Genius Bar. If you continue to enter the wrong password, you will be locked out of your iPhone, and your data will be unaccessable.

  • Speed/performance of my mac mini (mid-2010) is very slow. Need help, consolidate the files, software updates, etc. in order to improve the speed and performance.

    My mac mini (mid-2010) speed/performance is very slow - think of it as a result of letting my kids do "whatever" about it in recent years.  Need help, consolidate the files, software updates, etc. in order to improve the speed and performance.  You will also need to get data out of old PowerBook G4.

    < object edited by host >

    We are users like you.  Search locally by using something like Yelp or similar

    http://www.Yelp.com/search?find_desc=Apple+repair & find_loc = Chicago, + IT & start = 0 & ortby = rating s

    or read a few links which may be relevant on this forum about the slow mac mini

    http://BFY.tw/5C63

  • Satellite Pro A300-15V, I need help in the Organization of my startup list

    Hello everyone!

    I need help in the Organization of my startup list:

    (Why should Toshiba button support I this program if my laptop doesn't have multimedia keys? OR maybe this program for something else?)
    ItSecMng (although I have disabled the Bluetooth Manager to run when starting from this point still remains in the startup)
    Agent of filtering of Audio Conexant high definition (what is this program? Do I really need to start?)
    TOSHIBA Power Saver
    Toshiba Flash Cards
    RAID event monitor

    So, my friends. Could you give a valuable suggestion whether or not it is prudent to disable startup above entries? I want to speed up my laptop at the highest possible level.

    Thanks a lot for your time!

    Kind regards
    Osman.

    My laptop:

    Toshiba Satellite Pro A300-15V (PSAJ5E) => NOT have multimedia keys except the FN keys.

    > Toshiba Button support (why should I this program if my laptop doesn't have multimedia keys? OR maybe this program for something else?)
    You can disable it. If your mobile phone does not support the multimedia buttons then this tool is useless.

    > ItSecMng (although I have disabled the Bluetooth Manager to run when starting from this point still remains in the startup)
    I don't know what would make this process, but you can disable this in msconfig-> tab start Mr. If it would take in the future, then you could turn it on again.

    > Agent of filtering the Conexant high definition Audio (what is this program? Do I really need to start?)
    I think that this is necessary. It could improve your audio

    > Toshiba Power Saver
    This is important. It s an additional saving of Toshiba option for Win 7

    > Toshiba Flash Cards
    This tool controls the FN keys.

    > RAID Event Monitor
    Hmm so you don t have two hard disks, then you can try to disable it too.

  • I need help to the new photo of my photos from iphoto on El Capitan. Any help would be appreciated.

    I need help to the new photo of my photos from iphoto on El Capitan. Any help would be appreciated.

    To migrate your iPhoto library to Photos for Mac, drag it in the Photos icon in the Dock.  Photos will read the iPhoto library and create a new library of pictures of him.

    Is your photo library in iPhoto on an external drive? The migration will work that if the external hard drive Mac OS extended (journaled) file system.  If the library is on a disk with a different file system, Ministry of the environment of the library of a correctly formatted disk.

  • I need help for the upgrade of my current system.

    I need help for the upgrade of my current system.

    I have SBS 2008 with (Exch 2007, SQL 2005, Sharepoint, backupexec 2010 for sbs) licenses.

    I want to make the larger environment using the following:

    (1) apply Virtualization

    (2) apply to the failover process (clustering)

    "(3) the environment must support adding server terminal server, ERP server, exchange server, domain controller, backup manager.

    Storage 4) that supports Raid (1 and 5)

    UTM excellent 6) that supports (SSL VPN, VPN Global)

    suitable backup solution 7)

    (8) good antivirus for clients

    my questions:

    (1) can you provide me with a good design for this environment

    (2) should I choose what operating system:

    Microsoft datacenter or company

    I know datacenter provide us the unlimited VM but needs per processor license

    so if I have two Grouped servers I want to buy 4 licenses

    and just 4 VMs per company license... to say that we have two servers and maintain 8 vms so wat happened if 1 goes down... How can I migrate the 4 virtual machines on the server failed to another server group... ? should I buy enterprise license?

    (3) if I get the SAN storage for data... How can I save this storage... should I get another SAN?

    (4) how can I upgrade SBS stad single server (windows standrad) without losing the licenses as Exch 2007, SQL 2005, sharepoint.is it a must to buy an edition full std server or there is a way to upgrade (license wise, I mean)?

    (5) what about win2k8 license for VM:

    lets say we have physical that has windows license so that enough to have windows for VM or should I buy windows for VM licenses?

    (6) can I use backExec license for SBS with windows 2008 standard

    (7) who better to virtualization AMD or INTEL

    (8) hyper V or VMware?

    (9) what of Microsoft data protection Manager... is this good?

    (10) what virtual machine manager? What are the benefites keys

    Thanks in advance

    Hello AnasAI,

    You can find the Server forums on TechNet support, please create a new post at the following link:

    http://social.technet.Microsoft.com/forums/en/category/WindowsServer/

  • hp2544 need help on the installation of the first.

    I just buy a 2544 I bought it because of the impression of ipdad capabilities.

    The thing is that I have also recommended my sister bought one and it does not have a laptop or PC. She lives 100 miles so sharing mine is not an option. She bought his first and he's now sitting in the waiting area for me to tell how to install it on its network. She has a hub of sky.

    I searched and can't find any instructions can anyone help please?

    Hi spanisheyes.

    Welcome to the HP Forums!

    I understand that you need help setting up your HP Deskjet 2544 to your iPad, and I'm happy to help with this problem!

    Please take a look through these two guides:

    Hope this helps, and hope to hear from you!

  • Need help finding the product key.

    Here, can anyone help me find the product key of Norton antivirus software that came pre-installed with my hp Pavilion 15' inch laptop notebook pc. I need to update the software and I can't do it without the key.
    Impatient in waiting.

    If the product is installed (Norton _) - it would be better to contact them (Symantec / Norton) support - as it's their product and they will be able to tell you where to look.

    otherwise, you can try third-party products like Belarc Advisor - that should give you said information if it exists on the system.

  • I need help on the matrix of action script 3.0

    I need help on the matrix of action script 3.0

    [Ask in the correct forum allows... Left non-technical Forum Lounge for forum specific program... MOD]

    to apply a matrix for mc mat oppose:

    var mat: Matrix = new Matrix;

    mat.a = Whatever;

    mat.b =

    mat.c =

    mat.d =

    mast. TX =

    mat.Ty =

    MC. Transform.Matrix = Matt;

  • Need help for the license

    Hi all

    I need help license the following environment:

    1 400 VDIs.

    2. associated VDI servers.

    3-8 non - VDI associated servers.

    This environment runs on 6 dual CPU servers.

    Concerning

    For this, but all these already include vSphere, ESX and vCenter licenses.

    Advanced also include VSAN.

    Advanced horizon is available as simultaneous user and username, so if you can choose what type of license would be the most suitable for you, in most cases, the concurrency model is best suited.

    So say you have 400 concurrent users, you need 400 advanced Horizon permits and are then all included vSphere licenses.

    Linjo

Maybe you are looking for

  • How can I stop to iCloud by car, upload documents?

    How to choose the programs to download in iCloud drive

  • Layout of Satellite C660 - 14 X - wireless disappeared

    Hello! Have a big problem on my PC!When I formatted my pc today, all the drivers in the computer had disappeared. I don't know how many drivers I installed to make the wireless to work! I can't find any drivers that will work. Need help with this ple

  • JO HP 8620 pro: copy

    To copy via flat on printing is only half of the original print.as a solution. Steven4682

  • Real-time scanning and firewall disabled

    Every time I turn off my pc, the sacnning in real-time and the firewall are disable... and it happed after I purchsed online McFee, I used to have Panda Antivirus for Netbooks and used to work in perfect! I will never againg buy McAfee products, I to

  • How to access controls QML custom in C++ code...?

    Hi all I create a custom dialog to display the loading popup and it successfully added in the QML code but I don't get way to access this dialog box in the code c ++ to close when the network connection is closed and the response is received from the