0

こんにちは、私はすでにここに投稿しました:

SSIS パッケージの実行でいくつかの問題に直面しています。実際には非常に時間がかかります。多くの制約があるため、1対1で解決しようとしています! まず、720,000 行を抽出するのに 3 時間以上かかるというクエリから始めます。

Select 
    --11 fields from tbl1
    Tbl1.field1 As field1,
    ….
    .
    .
    Tbl1.field11 As field11,

    CASE WHEN (dbo.tbl1.field11 = 'J') 
                          THEN N'Batch' ELSE dbo.tbl1.field11 END AS creation_oprid, CONVERT(date, tbl1.date1) 
                          AS creation_date, CONVERT(date, tbl1.date2) AS update_date, 
                          CASE WHEN (dbo.tbl1.field12 = 'J') 
                          THEN N'Batch' ELSE dbo.tbl1.field12 END AS update_oprid, 
    tbl1.id, 

    --3 fields from tbl2

    Tbl2.field1 As field1,
    ….
    .
    .
    Tbl2.field3 As field3,

    Tbl3.field1 As field1,
    Tbl4.field1 As field1,
    Tbl3_2.field1 As field1,

    --30 fields from tbl5
    Tbl5.field1 As field1,
    ….
    .
    .
    Tbl5.field30 As field30,

    --7 fields from tbl6

    Tbl6.field1 As field1,
    ….
    .
    .
    Tbl6.field7 As field7,

    --5 fields from tbl7

    Tbl7.field1 As field1,
    ….
    .
    .
    Tbl8.field5 As field5,


    --7 fields from tbl8

    Tbl8.field1 As field1,
    ….
    .
    .
    Tbl8.field7 As field7,

    --

    ---6 conditions from the same table and the same field and 6 conditions with AND

      CASE WHEN tbl9.field1 = N'Value1' THEN tbl9.field2 END AS XXX1,
      CASE WHEN tbl9.field1 = N'Value1' THEN tbl9.field2 AND
      Tbl9.field3= 'SAMEValue' THEN N'Batch' ELSE Tbl9.field3 END AS YYY1,

    .
    .
      CASE WHEN tbl9.field1 = N'Value6' THEN tbl9.field2 END AS XXX6,
      CASE WHEN tbl9.field1 = N'Value6' THEN tbl9.field2 AND
      Tbl9.field3= 'SAMEValue' THEN N'Batch' ELSE Tbl9.field3 END AS YYY6,

    Tbl3_4.field1 As field1,
    Dbo.tbl10.field1 As field1,
    Dbo.tbl10_1.field1 As field1,


    CASE WHEN dbo.tbl8.TYPE_ID = 9 THEN N'Y' WHEN dbo. dbo.tbl8.TYPE_ID = 10 THEN N'N' END AS
                           flag, 
    CASE WHEN dbo.tbl11.field_ID IS NOT NULL 
                          THEN ('O_' + dbo.tbl11.field_ID) END AS field_ID, 
    CASE WHEN dbo.tbl12.field_ID IS NOT NULL THEN ('L_' + dbo.tbl12.field_ID) END AS field_ID
                        ,ROW_NUMBER() OVER (ORDER BY id,dbo.tbl8.FIELDID,dbo.tbl8.Field2ID) AS RowNumber



    FROM         
    dbo.tbl1 
    INNER JOIN dbo.tbl8 
        ON tbl1.field_ID = Tbl8.contact_field_ID 
    LEFT OUTER JOIN dbo.tbl12 
        ON dbo.TBL1.PERSON_ID = dbo.tbl12.FIELD_ID_CONTACT 
    LEFT OUTER JOIN dbo.PS_RSF_OPP_CONTACT 
        ON dbo.TBL1.PERSON_ID = dbo.tbl11.FIELD_ID_CONTACT 
    LEFT OUTER JOIN dbo.tbl3 AS tbl3_4 
        ON TBL1.COMM_METHOD = tbl3_4.FIELDVALUE AND (FIELDNAME = N'VALUE') AND (EFF_STATUS = N'A') 
    LEFT OUTER JOIN dbo.tbl9 
        ON TBL1.FIELD_ID = tbl9.FIELD_ID 
    LEFT OUTER JOIN dbo.tbl5 
        ON TBL1.FIELD_ID = tbl5.FIELD_ID 
    LEFT OUTER JOIN dbo.tbl7 
        ON TBL1.FIELD_ID = tbl7.FIELD_ID 
    LEFT OUTER JOIN tbl6
        ON TBL1.FIELD_ID = tbl6.FIELD_ID 
    LEFT OUTER JOIN dbo.tbl10 AS tbl10_1 
    RIGHT OUTER JOIN dbo.tbl13 
        ON tbl10_1.CM_PURPOSE_TYPE_ID = dbo.tbl13.CM_PURPOSE_TYPE_ID 
        ON TBL1.FIELD_ID = tbl13.FIELD_ID 
    LEFT OUTER JOIN dbo.tbl10 
    RIGHT OUTER JOIN dbo.tbl14 
        ON dbo.tbl10.CM_PURPOSE_TYPE_ID = dbo.tbl14.CM_PURPOSE_TYPE_ID 
        ON TBL1.FIELD_ID = tbl14.FIELD_ID 
    LEFT OUTER JOIN dbo.tbl3 AS tbl3_2 
        ON TBL1.PRSN_TYPE = tbl3_2.FIELDVALUE AND (tbl3_2.FIELDNAME =          N'PRSN_TYPE') 
        AND (tbl3_2.EFF_STATUS = N'A') 
    LEFT OUTER JOIN dbo.tbl4 
        ON TBL1.FIELD_CD = TBL4.FIELD_CD 
    LEFT OUTER JOIN dbo.tbl3 AS tbl3 
        ON TBL1.Field_CD = tbl3.FIELDVALUE AND (tbl3.FIELDNAME = N' LANG') 
        AND (tbl3.EFF_STATUS = N'A') 
    LEFT OUTER JOIN dbo.tbl2 AS tbl2 
        ON TBL1.FIELD_ID = tbl2.FIELD_ID AND (tbl2.PRIMARY_IND = 'Y')
    ORDER BY dbo.TBL1.PERSON_ID

ご協力ありがとうございました

4

0 に答える 0