Re: ridiculously time-consuming subqueries
From: David Fitzjarrell <oratune_at_yahoo.com>
Date: Wed, 12 Mar 2014 11:24:47 -0700 (PDT)
Message-ID: <1394648687.80968.YahooMailNeo_at_web124704.mail.ne1.yahoo.com>
Date: Wed, 12 Mar 2014 11:24:47 -0700 (PDT)
Message-ID: <1394648687.80968.YahooMailNeo_at_web124704.mail.ne1.yahoo.com>
I have to ask which release of Oracle are you using? Second, does subquery factoring help any (using WITH)? You could combine those two queries into one WITH query. To know why these are taking so long we'll need to see plans for each of the queries (I suspect the plans will be the same). David Fitzjarrell Primary author, "Oracle Exadata Survival Guide" On Wednesday, March 12, 2014 11:52 AM, William Threlfall <William.Threlfall_at_albertahealthservices.ca> wrote: Hi experts, I have a query in which I am trying to get the CMV and EBV results for the patient’s last transplant. I put in the following subquery code: (SELECT RECIPIENT_CMV_IGG FROM PAT_TRANSPLANT PT, SDF_SEROLOGY_VERIFICATION_TO SV, DOCUMENTS DOCS, TX_DOCUMENTS TXD WHERE PT.PAT_ID = PD.PAT_ID AND PT.PAT_ID = DOCS.PAT_ID AND PT.PAT_ID = LTV.PAT_ID AND PT.TRANSPLANT_ID = TXD.TRANSPLANT_ID AND PT.DATE_OF_TRANS = LTV.LAST_TRANS_DATE AND DOCS.DOC_ID = TXD.DOC_ID AND DOCS.DOC_ID = SV.DOC_ID AND DOCS.DOC_KIND_ID = 10108 ) AS CMV, (SELECT RECIPIENT_EBV FROM PAT_TRANSPLANT PT, SDF_SEROLOGY_VERIFICATION_TO SV, DOCUMENTS DOCS, TX_DOCUMENTS TXD WHERE PT.PAT_ID = PD.PAT_ID AND PT.PAT_ID = DOCS.PAT_ID AND PT.PAT_ID = LTV.PAT_ID AND PT.TRANSPLANT_ID = TXD.TRANSPLANT_ID AND PT.DATE_OF_TRANS = LTV.LAST_TRANS_DATE AND DOCS.DOC_ID = TXD.DOC_ID AND DOCS.DOC_ID = SV.DOC_ID AND DOCS.DOC_KIND_ID = 10108 ) AS EBV In the above code, PD = PATIENT_DEMO and LTV = LAST_TRANSPLANT_VIEW, which are in the FROM clause in the main query. When I comment out these subqueries, the rest of the main query executes in less than 5 minutes, but with these subqueries in I had to stop the query because it was running for over an hour and still wasn’t finished yet. Can anyonesee any obvious explanation for why these subqueries are taking so long to execute? Can anyonesuggest a better way to get the CMV and EBV results for the last transplant? I only want one CMV and one EBV result(i.e. one value for each, in one row) returned per patient. I am not certain if there are multiple 10108 documentsattached to the last transplantfor any patients -that is possible. In that case I want the resultto be “POSITIVE”if any of them are POSITIVE, otherwise “NEGATIVE”. Thanks, - Bill. _______________________________________ Willliam J. (Bill) Threlfall, MSc Clinical Informatics Coordinator - OTTR Transplant Services, University of Alberta Hospital Alberta Health Services Aberhart Centre, Room 9221 8440 112 Street Edmonton, AB T6G 2B7 Telephone: 780-407-6175 FAX: 780-407-8981 Alberta Health Services www.albertahealhservices.ca This message, and any documents attached hereto, is intended only for the addressee and may contain privileged or confidential information. any unauthorized disclosure is strictly prohibited. If you have received this message in error, please notify us immediately so that we may correct our internal records. Please then delete the original message. Thank you. ________________________________ This message and any attached documents are only for the use of the intended recipient(s), are confidential and may contain privileged information. Any unauthorized review, use, retransmission, or other disclosure is strictly prohibited. If you have received this message in error, please notify the sender immediately, and then delete the original message. Thank you.
-- http://www.freelists.org/webpage/oracle-lReceived on Wed Mar 12 2014 - 19:24:47 CET