Postgresql-Abfrage braucht Zeit

#1:

FEHLER: fehlender FROM-Klauseleintrag für Tabelle "icm"
ZEILE 39: )att)afa auf icm.icsr...
                                                ^
SQL-Status: 42P01
Charakter: 2000

#2: Ich habe es anders versucht, aber das dauert zu lange (3+ Stunden). Der so geänderte Projektcode kann leider nicht eingefügt werden.


Fordern Sie an, den gesamten Postgresql-Code zu überprüfen und Zeit und Fehler zu reduzieren

--- Oder ein


     WÄHLEN Sie I.inv_test_id_0072
           aus Inv i,
                 icm icm,
                 gbm,
                 icc,
                 cst c,
                 ce ce,
                 co cc,
                 er2 e,
                 mtt.wrk w,
                 dh dh,
                 mtt.wt wt,
                 mtt.wll wl,
                 mtt. wa wa,
                 mtt.wpp wp,
                 mtt.mtt_psnl cp,
                 (Select WorkFlow_ARC_WFID,warfn,WorkFlow_ARC_WFNO from (select wiid WorkFlow_ARC_WFID,isrn warfn,arc_no_729 WorkFlow_ARC_WFNO from
                 mtt.workflow,gcars.inv_mtt_mapping,gcars.arc,ic
                 wo
                 isrn = srn
                 und srn = arc_no_729
                 und ARC_IC_NO_729=ic_NO_702
                 und ic_h2_702 in ('TSP','WAB')
                 )) WorkFlow_ARC,
                 (wählen Sie Kundennummer, COMM_INV_ID, COMM_RANK aus (wählen Sie isp.SCR_CUST_NO_722 Kundennummer,
                        isp.SCR_FINDER_NO_722 Finder_Nein,
                   
                        ii7 COMM_INV_ID,
                        RANK() OVER(PARTITION BY isp.SCR_CUST_NO_722, isp.SCR_FINDER_NO_722 ORDER BY isp.SCR_DATE_722 desc) COMM_RANK
                        Von inv, issp isp
                         wo isp.SCR_CUST_NO_722=inv_cust_no_720
                         und isp.SCR_FINDER_NO_722=INV_FINDER_NO_720
                         und scr_open_item_stat1_722 ist null
                         ) COMMM wobei COMM_RANK=1) COMM ,
                  
                 (Select W_ID,WC_INV_ID,CommentText,Comment_Rank from (select Distinct w.wiid W_ID,INV_ID WC_INV_ID,
                         WORKFLOW_COMMENT KommentarText,
                         RANK() OVER(PARTITION BY WC.wiid, WC.WORKFLOW_LOG_ID ORDER BY WC.WORKFLOW_LOG_ID desc) Comment_RANK
                         von inv_mtt_mapping,
                         mtt.wll WL,
                         mtt.wfc WC,
                         mtt.wf W,
                         mtt.wfa WA,
                         mtt.mtt_psnl p
                     wo
                     isrn = srn
                     Und wl.log_wiid = w.wiid
                     und p.SSO_ID = WL.log_sso_id
                     und WC.wiid = W.wiid
                     und WL.log_id = WC.Workflow_Log_id
                     und wA.Workflow_Action_Id = wl.log_action_id
                     und UPPER(WA.LOG_ACTION_DESC) = 'REQUESTED') COMnt wo Comment_RANK=1) inic,
                
                 gem,
                    
                 (wählen Sie arc_no,ARC_INV_ID, arc_sso_id, arc_pers_name
                     from (wählen Sie verschiedene inv.ii7 ARC_INV_ID,
                                   m.arc_nr_829 arc_nr,
                                   m.arc_sso_id_829 arc_sso_id,
                                   m.arc_pers_name_829 arc_pers_name,
                                   rank() over(partition by m.arc_no_829 order by m.timestamp desc, arc_sso_id_829 desc) rankt
                                 aus inv, aic, gcars.arc m
                                   wo
                                   ccn6=cn7
                                 
                                   und m.arc_role_829 = 'DO'
                                        und (m.arc_to_dt_829 ist null oder
                                               m.arc_to_dt_829 >= trunc(sysdate)))
                     wobei Ränge = 1) do_arcrole,
                    
                 (wählen Sie arc_no,ARC_INV_ID_DC, arc_sso_id, arc_pers_name
                     from (wählen Sie verschiedene inv.ii7 ARC_INV_ID_DC,
                                   m.arc_no_829 arc_nr,
                                   m.arc_sso_id_829 arc_sso_id,
                                   m.arc_pers_name_829 arc_pers_name,
                                   rank() over(partition by m.arc_no_829 order by m.timestamp desc, arc_sso_id_829 desc) rankt
                                   aus inv, aic, gcars.arc m
                                  hier
                                   ccn6=cn7
                                 
                                   und m.arc_role_829 = 'DC'
                                        und (m.arc_to_dt_829 ist null oder
                                               m.arc_to_dt_829 >= trunc(sysdate)))
                     wobei Ränge = 1) dc_arcrole,
                 arc_comment
                Wobei i.ii7 = icm.inv_id
              
                      und icm.isrn = w.srn
                  
                       und i.ii7 = ie.inv_id_730
                       und INITIAL_COMMENT.W_ID = W.wiid
                       und i.ii7 = INITIAL_COMMENT.WC_INV_ID
                       und cp.SSO_ID = wl.log_sso_id
                       und wt.workflow_type_id = w.workflow_type
                       und w.wiid nicht in (1, 2)
                       und w.wiid = wp.wiid(+)
                       und






---Postgresql


WÄHLEN
     i.inv_test_id_0072
VON
     test.inv i
     LEFT OUTER JOIN test.act ON ( inv_cre_an_720 = an_729 )
     LEFT OUTER JOIN actc ON ( an_729 = an_689 ), --test.inv_cmt_mapping icm, gebm, test.icc, test.cust c,
     test.ce ce, test.co cc, test.er e,
     atc.wrk w LEFT OUTER JOIN atc.wp wp ON w.wiid = wp.wiid LEFT OUTER join atc.wl wl ON (w.wiid = lwiid)
     LEFT OUTER JOIN atc.wa wa ON (wl.laci = wa.wiiad und wa.acc = 6),
     test.iee dh atc.wtt wt, --atc.wl wl, --atc.wa wa, --atc.wpp wp,
     atc.mtc_psnl cp left join (Wählen Sie wfid,wfrn,WorkFlow_ARC_WFNO
     from (wählen Sie wiid wfid,icm.icsrn wfrn,
     an7 wfnn von atc.workflow,test.invcm,test.arc,test.invc,
    
     test.invcm icm
     WO icm.icsrn =
     (CASE WENN srn NULL IST ODER srn='' THEN '0' ELSE srn END )::NUMERIC
     und srn::numeric = an7 und ain9=in2 und ih2 in ('TSP','WAB')
     )att)wfrc on icm.icsrn=wfrc.wfrn left join (Wählen Sie wfid,wfrn,wfnn
     from (wählen Sie wiid wfid,icsrn wfrn,
     an7 wfnn von
     atc.workflow,test.invcm,test.arc,test.invc
     WO icsrn =
     (FALL --srn
     WHEN srn IST NULL ODER srn='' THEN '0' ELSE srn END ::NUMERIC
     und srn::numeric = an7 und ain9=in2
     und ih2 in ('TSP','WAB')
     )att)wfrc ein (w.srn=wfrc.wfrn)
     left join (wählen Sie Kunden_Nr., Finder_Nr., SP_Datum, Kontakt_Typ,
     contact_result,next_Action,COMM_INV_ID,COMM_RANK from (select isp.SCR_CUST_NO_722 Cust_No,
     isp.SCR_FINDER_NO_722 Finder_Nr, isp.SCR_DATE_722 SP_Datum,
     isp.SCR_CONTACT_TYPE_722 Kontakttyp, SCR_CONTACT_RESULT_722 Kontaktergebnis,
     SCR_NEXT_ACTION_722 next_Action, inv_test_id_0072 COMM_INV_ID,
     RANK() OVER(PARTITION BY isp.SCR_CUST_NO_722, isp.SCR_FINDER_NO_722 ORDER BY isp.SCR_DATE_722 desc) COMM_RANK
     Aus test.inv, test.inv_scratch_pad isp wobei isp.SCR_CUST_NO_722=inv_cust_no_720
     und isp.SCR_FINDER_NO_722=INV_FINDER_NO_720 und scr_open_item_stat1_722 ist null

) COMMM wo COMM_RANK=1) COMM an (i.inv_test_id_0072 = COMM.COMM_INV_ID),
     (Wählen Sie W_ID, WC_INV_ID, Kommentartext, Kommentarrang aus
     (wählen Sie Distinct w.wiid W_ID,INV_ID WC_INV_ID,
     WORKFLOW_COMMENT CommentText, RANK() OVER(PARTITION BY WC.wiid, WC.WORKFLOW_LOG_ID
     ORDER BY WC.WORKFLOW_LOG_ID desc) Comment_RANK aus test.invcm,
     atc.workflow_log WL, atc.Workflow_Comments WC,
     atc.Workflow W, atc.Workflow_actions WA,
     atc.mtc_psnl p WO icsrn =
     (CASE WENN srn NULL IST ODER srn='' THEN '0' ELSE srn END )::NUMERIC
     Und wl.lwiid = w.wiid und p.SSO_ID = WL.log_sso_id
     und WC.wiid = W.wiid und WL.log_id = WC.Workflow_Log_id
     und wA.wiiad = wl.laci
     und UPPER(WA.LOG_ACTION_DESC) = 'REQUESTED') COMnt wo Comment_RANK=1) INITIAL_COMMENT--,
     --Bogen,
     left join (wählen Sie eine,ARC_INV_ID, asid, apn
     from (wählen Sie eindeutige inv.inv_test_id_0072 ARC_INV_ID,
     rank() over(partition by m.an_829 order by m.timestamp desc, arc_sso_id_829 desc) Ränge
    
     aus inv, aicv, test.arc m wo
     ccn6=icn7 und m.arc_role_829 = 'DO'
     und (m.arc_to_dt_829 ist null oder m.arc_to_dt_829 >= date_trunc('day',CURRENT_DATE)))aats
     wobei Ränge = 1) do_arcrole on (an7 = do_arcrole.an)
      links

BEITRETEN (
         WÄHLEN
             ein,
             arc_inv_id,
             arc_sso_id,
             apn
         VON
             (
                 WÄHLEN SIE UNTERSCHIEDLICH
                     inv.inv_test_id_0072 arc_inv_id,
                     RANG() ÜBER(
                         PARTITION DURCH m.an_829
                         SORTIEREN NACH
                             m.timestamp DESC, arc_sso_id_829 DESC
                     ) Reihen
                 VON
                     inv,
                     arc_inv_connector,
                     test.arc_roles m
                 WO
                     ccn6 = icn7
                     UND m.arc_role_829 = 'TUN'
                     UND (m.arc_to_dt_829 IST NULL
                           ODER m.arc_to_dt_829 >= date_trunc('day', current_date) )
             ) aat
         WO
             Ränge = 1
     ) do_arcrole EIN ( i.inv_test_id_0072 = do_arcrole.arc_inv_id )
LINKS VERBINDEN
                 ( WÄHLEN
     ein,
     arc_inv_id_dc,
     arc_sso_id,
     arc_pers_name
VON ( AUSWÄHLEN DISTINCT
     inv.inv_test_id_0072 arc_inv_id_dc,
     m.an_829 ein,
     m.arc_sso_id_829 arc_sso_id,
     m.arc_pers_name_829 arc_pers_name,
                                               WO
                                               UND m.arc_role_829 = 'DC' m.arc_to_dt_829 >= date_trunc('day',CURRENT_DATE)))asww
WO Ränge = 1) dc_arcrole ON (
   an7 = dc_arcrole.an
)
LINKS VERBINDEN
(
        WÄHLE ein,
               arc_inv_id_dc,
               arc_sso_id,
               arc_pers_name
        WO Ränge = 1) dc_arcrole ON (
   i.inv_test_id_0072 = dc_arcrole.arc_inv_id_dc
)
--arc_comment
WO i.inv_test_id_0072 = icm.inv_id
-- und icm.icsrn = w.srn
UND
icm.icsrn = (
FALL
WENN srn NULL IST
   ODER
   srn='' DANN
   '0'
   ELSE srn
ENDE ): :numerisch
UND i.inv_test_id_0072 = dh.inv_id_730
     UND inkl.w_id = w.wiid
         UND i.inv_test_id_0072 = inkl.wc_inv_id
             UND cp.sid = wl.lsid
                 UND wt.wti = w.workflow_type
                     UND w.wiid NICHT IN (
     1,
     2
)
                         UND icst = cn7
                             UND inv_ic_no_720 = in2
                                 UND ih2 IN (
     'TSP',
     'WAB'
)
                                     UND ce.ci2 = ci7
                                         UND ccn7 = cc.cn7
                                             UND e.ext = 'CM'
                                                 UND e.ecf = inv_curr3_720
                                                     AND e.ect = 'USD'
                                                         UND pid5 = ih2
                                                             UND Gebot5 = ic_h3_702
                                                                 UND sbi5 = ic_h4_702 BESTELLUNG
     von w.wiid;

das ist schwer bis gar nicht nachvollziehbar. Aus was soll sich Zeile 39 beziehen? Warum hast Du das SQL ins deutsche übersetzt? Wenn da aus SELECT ein WÄHLEN wird wird es schwer lesbar.

Ah, die Fehlermeldung kommt wohl von

WÄHLEN
     i.inv_test_id_0072
VON
     test.inv i
     LEFT OUTER JOIN test.act ON ( inv_cre_an_720 = an_729 )
     LEFT OUTER JOIN actc ON ( an_729 = an_689 ), --test.inv_cmt_mapping icm, gebm, test.icc, test.cust c,
     test.ce ce, test.co cc, test.er e,
     atc.wrk w LEFT OUTER JOIN atc.wp wp ON w.wiid = wp.wiid LEFT OUTER join atc.wl wl ON (w.wiid = lwiid)
     LEFT OUTER JOIN atc.wa wa ON (wl.laci = wa.wiiad und wa.acc = 6),
     test.iee dh atc.wtt wt, --atc.wl wl, --atc.wa wa, --atc.wpp wp,
     atc.mtc_psnl cp left join (Wählen Sie wfid,wfrn,WorkFlow_ARC_WFNO
     from (wählen Sie wiid wfid,icm.icsrn wfrn,
     an7 wfnn von atc.workflow,test.invcm,test.arc,test.invc,

     test.invcm icm
     WO icm.icsrn =
     (CASE WENN srn NULL IST ODER srn='' THEN '0' ELSE srn END )::NUMERIC
     und srn::numeric = an7 und ain9=in2 und ih2 in ('TSP','WAB')
     )att)wfrc on icm.icsrn=wfrc.wfrn left join (Wählen Sie wfid,wfrn,wfnn

An dieser Stelle ist ganz offensichtlich keine Tabelle icm in der Lister der Quelltabellen definiert.

Was die Abfragezeit betrifft: nutze EXPLAIN bzw. EXPLAIN ANALYSE, um anhand des Planes zu sehen, WO diese Zeit verloren geht.

Dieses Thema wurde automatisch 60 Tage nach der letzten Antwort geschlossen. Es sind keine neuen Antworten mehr erlaubt.