2016-08-25 5 views
9

से SQLServer प्रकाशन हमारे ग्राहक में से एक में Oracle 10.2.0.5 आरएसी (एचपीयूएक्स) और दो SQL सर्वर 2012 (Windows server 2008R2) हैं। और हम उन्हें ओरेकल से SQL सर्वर तक डेटा प्रकाशित करने में मदद कर रहे हैं। उन्हें यह भी जानने की आवश्यकता है कि कौन सी पंक्तियां जोड़ दी गई हैं, अपडेट की गई हैं और हटा दी गई हैं, लेकिन वे अपने ऐप्स को संशोधित नहीं करना चाहते हैं।ओरेकल

पूरी बात इस तरह काम करता है: - वितरक के रूप में> एसक्यूएल सर्वर एक - प्रकाशक के रूप में

ओरेकल> एसक्यूएल सर्वर बी सदस्य के रूप में

हमारे डीबीए SSMS के माध्यम से सभी डीबीएस कॉन्फ़िगर किया गया था (एसक्यूएल सर्वर प्रबंधन स्टूडियो) इस Create a Publication from an Oracle Database की तरह। यह कई दिनों के लिए बहुत अच्छी तरह से काम किया। लेकिन ओरेकल का प्रदर्शन खराब और बदतर हो रहा है। अंत में, हमें ओरेकल के डेटा प्रकाशन को रोकना होगा।

यह पता चला है कि, एसएसएमएस ओरेकल में "एचआरईपीएल" नामक एक पैकेज तैयार करेगा, जिसमें "PollEnd" नामक एक प्रक्रिया है। "PollEnd" तालिका में डेटा हटाने के लिए बहुत उच्च आवृत्ति में निष्पादित किया जाएगा "HREPL_ARTICLE1LOG_1"। लेकिन समय के साथ "PollEnd" का निष्पादन समय बढ़ता है। अंत में, निष्पादन समय निष्पादित करने के समय से अधिक लंबा होता है, और तालिका बंद हो जाती है, और ओरेकल का प्रदर्शन बहुत खराब होगा।

और हम यहां फंस गए।

क्या किसी को यह पता है कि इसे कैसे ठीक किया जाए? कृपया सहायता कीजिए!

"PollEnd" प्रक्रिया:

----------------------------------------------------------------------------------- 
-- 
-- Name: PollEnd 
-- Purpose: PollEnd request signifies that the change entries identified with the current 
--   interval have been successfully entered into the store and forward database 
--   and can be deleted from the article log tables. 
-- Input: 
--   argLSN   IN RAW(10)  LSN from distributor that was associated 
--           with this poll interval 
-- Output: 
-- Notes: This request causes those entries of the article log tables represented in the 
--   Poll Table and having the current pollid to be deleted from both their article log 
--   tables and from the Poll Table. The last request value is updated to reflect a 
--   PollEnd request. 
-- 
----------------------------------------------------------------------------------- 
PROCEDURE PollEnd 
(
    argLSN  IN RAW 
) 
AS 
    SQLCommand  VARCHAR2(500); 
    LogTable  VARCHAR2(255); 
    CurrentPollID NUMBER; 
    TableIDs  number_tab; 
    InstanceIDs  number_tab; 
    IDCount   BINARY_INTEGER; 
    PublisherLSN RAW(10); 

BEGIN 
    -- Put the published tableIDs in a PL/SQL table of IDs 
    HREPL.GetTableIDs(TableIDs, InstanceIDs); 

    -- Get the current Poll ID 
    SELECT Publisher_CurrentPollid INTO CurrentPollID FROM HREPL_Publisher; 

    IDCount := TableIDs.COUNT; 
    -- For each table represented in the ID list 
    FOR id_ind IN 1 .. IDCount 
    LOOP 

     LogTable := REPLACE(REPLACE(ArticleLogTemplate, MatchString, TO_CHAR(TableIDs(id_ind))), 
                 MatchStringY, TO_CHAR(InstanceIDs(id_ind))); 

     BEGIN 
      -- Generate command to delete from the article log those entries appearing in the 
      -- Poll Table with the current PollID 
      SQLCommand := 'DELETE FROM ' || LogTable || ' l ' || 
           'WHERE EXISTS (SELECT p.POLL_POLLID FROM HREPL_POLL p ' || 
           '    WHERE CHARTOROWID(l.ROWID) = p.Poll_ROWID ' || 
           '    AND p.Poll_PollID = :Pollid)'; 

      HREPL.ExecuteCommandForPollID(SQLCommand, CurrentPollID); 

     EXCEPTION 
      WHEN OTHERS THEN NULL; 
     END; 
    END LOOP; 

    FOR POLLID IN (SELECT CurrentPollid FROM DUAL) 
    LOOP 
     -- Delete from HREPL_Event those entries appearing in the Poll Table 
     -- with the current PollID. 
     DELETE FROM HREPL_Event e 
     WHERE EXISTS (SELECT p.POLL_POLLID FROM HREPL_POLL p 
         WHERE CHARTOROWID(e.ROWID) = p.Poll_ROWID 
         AND p.Poll_PollID = POLLID.CurrentPollID); 

     -- Delete entries from the Poll Table having the current Pollid 
     DELETE FROM HREPL_Poll 
     WHERE Poll_PollID = POLLID.CurrentPollID; 
    END LOOP; 

    -- Drop all views associated with articles that are marked as UnPublishPending. 
    -- Note: We cannot perform these drops in UnPublish table, since UnPublish 
    --  table can execute concurrently with PollBegin and the querying 
    --  of published tables by the log reader. PollEnd, however, executes 
    --  synchronously with respect to these activities, so can be used 
    --  to cleanup log tables and views that are no longer needed. 
    HREPL.CleanupLogsandViews; 

    -- Mark the last request as PollEnd, and update the Publisher LSN 
    -- to reflect the LSN committed at the publisher. 
    UPDATE HREPL_Publisher 
    SET Publisher_PollInProcess = NoPollInProcess, 
     Publisher_LSN = argLSN; 

    -- Commit transaction 
    COMMIT; 

EXCEPTION 
    WHEN OTHERS THEN 
     ROLLBACK; 
     RAISE; 

END PollEnd; 

संपादित करें 01:

पूर्ण पैकेज यहाँ है: HREPL

संपादित करें 02:

पिछले हम देते हैं पर अप। एमएस और ओरेकल एक दूसरे को दोष देते हैं।

हमने ओरेकल से एसक्यूएल सर्वर से डेटा कॉपी करने के लिए ओग का उपयोग करने की कोशिश की, जो एक गड़बड़ भी है।

अब हम ओरेकल से ऑरैकल में डेटा कॉपी करने के लिए अंडे का उपयोग करने की कोशिश कर रहे हैं।

सभी मदद के लिए धन्यवाद।

+1

इन जैसे मुद्दों को केवल एक प्रक्रिया को देखकर निदान करना मुश्किल है। क्या आपको पता है कि आपकी 'पोलएंड' प्रक्रिया का कौन सा हिस्सा बढ़ता निष्पादन समय से संबंधित है? और, 'आईडीकाउंट' कितना बड़ा है? समय बीतने के साथ ही यह संख्या नाटकीय रूप से बढ़ रही है? इसके अलावा (शायद असंबंधित), डुएल टेबल के माध्यम से लूप क्यों? उस तालिका में कभी भी एक से अधिक पंक्ति नहीं होने चाहिए। – MJH

+1

डेटा को डाउनस्ट्रीम सर्वर पर कितना अद्यतित होना चाहिए? – Bohemian

+0

@MJH मैंने पूरा पैकेज अपलोड किया है, जोड़ें, मैं आपको आवश्यक पैरामीटर के लिए हमारे डीबीए से पूछूंगा। – neohope

उत्तर

0

एकाधिक तालिका हटाएं वाक्यविन्यास का उपयोग करने के लिए अपने DELETE ... WHERE EXISTS (...) क्वेरी को कनवर्ट करें। अंत में

DELETE e 
FROM HREPL_POLL p, HREPL_Event e 
WHERE CHARTOROWID(e.ROWID) = p.Poll_ROWID 
    AND p.Poll_PollID = POLLID.CurrentPollID; 

, हटाने पूरी तरह से दोहरे अधिक LOOP - यह जो भी कुछ नहीं करता है,:

SQLCommand := 'DELETE l' || 
    ' FROM HREPL_POLL, ' || LogTable || 
    ' l WHERE CHARTOROWID(l.ROWID) = p.Poll_ROWID ' || 
    ' AND p.Poll_PollID = :Pollid)'; 

प्रत्येक शामिल मेज पर एक समारोह सूचकांक बनाएँ:

CREATE INDEX MYTABLE_CHARTOROWID ON MYTABLE(CHARTOROWID(ROWID)); 

और फिर आगे नीचे बस CurrentPollid का उपयोग कर इसके अंदर कोड को निष्पादित करें।

+0

पर पूछा जाना चाहिए यदि आप व्यर्थ लूप से छुटकारा पाएं, तो आपको लूप के अंदर 'POLLID.' संदर्भों को हटाना होगा। वैसे भी, यह संभावना नहीं है कि लूप के समग्र प्रदर्शन पर एक उल्लेखनीय प्रभाव पड़ता है। –

+0

@ammoQ कोड पर मेरी घृणा ने मेरे तर्कसंगत पक्ष को प्रभावित किया। मैंने सीधे 'CurrentPollid' का उपयोग करने के लिए मेरी टिप्पणी में संशोधन किया है। चीयर्स। – Bohemian

0

कुछ शामिल स्थितियां अनुचित लगती हैं, आप इस संस्करण के साथ अधिक भाग्यशाली हो सकते हैं - यदि आप इसे उत्पादन पर आज़माते हैं, तो आप इसे अपने जोखिम पर करते हैं!

----------------------------------------------------------------------------------- 
-- 
-- Name: PollEnd 
-- Purpose: PollEnd request signifies that the change entries identified with the current 
--   interval have been successfully entered into the store and forward database 
--   and can be deleted from the article log tables. 
-- Input: 
--   argLSN   IN RAW(10)  LSN from distributor that was associated 
--           with this poll interval 
-- Output: 
-- Notes: This request causes those entries of the article log tables represented in the 
--   Poll Table and having the current pollid to be deleted from both their article log 
--   tables and from the Poll Table. The last request value is updated to reflect a 
--   PollEnd request. 
-- 
----------------------------------------------------------------------------------- 
PROCEDURE PollEnd 
(
    argLSN  IN RAW 
) 
AS 
    SQLCommand  VARCHAR2(500); 
    LogTable  VARCHAR2(255); 
    CurrentPollID NUMBER; 
    TableIDs  number_tab; 
    InstanceIDs  number_tab; 
    IDCount   BINARY_INTEGER; 
    PublisherLSN RAW(10); 

BEGIN 
    -- Put the published tableIDs in a PL/SQL table of IDs 
    HREPL.GetTableIDs(TableIDs, InstanceIDs); 

    -- Get the current Poll ID 
    SELECT Publisher_CurrentPollid INTO CurrentPollID FROM HREPL_Publisher; 

    IDCount := TableIDs.COUNT; 
    -- For each table represented in the ID list 
    FOR id_ind IN 1 .. IDCount 
    LOOP 

     LogTable := REPLACE(REPLACE(ArticleLogTemplate, MatchString, TO_CHAR(TableIDs(id_ind))), 
                 MatchStringY, TO_CHAR(InstanceIDs(id_ind))); 

     BEGIN 
      -- Generate command to delete from the article log those entries appearing in the 
      -- Poll Table with the current PollID 
      SQLCommand := 'DELETE FROM ' || LogTable || ' l ' || 
           'WHERE l.ROWID IN (SELECT chartorowid(p.Poll_ROWID) FROM HREPL_POLL p ' || 
           '    WHERE p.Poll_PollID = :Pollid)'; 

      HREPL.ExecuteCommandForPollID(SQLCommand, CurrentPollID); 

     EXCEPTION 
      WHEN OTHERS THEN NULL; 
     END; 
    END LOOP; 

    -- Delete from HREPL_Event those entries appearing in the Poll Table 
    -- with the current PollID. 
    DELETE FROM HREPL_Event e 
     WHERE ROWID in (SELECT chartorowid(p.Poll_ROWID) FROM HREPL_POLL p 
         WHERE p.Poll_PollID = CurrentPollID); 

     -- Delete entries from the Poll Table having the current Pollid 
    DELETE FROM HREPL_Poll 
     WHERE Poll_PollID = CurrentPollID; 

    -- Drop all views associated with articles that are marked as UnPublishPending. 
    -- Note: We cannot perform these drops in UnPublish table, since UnPublish 
    --  table can execute concurrently with PollBegin and the querying 
    --  of published tables by the log reader. PollEnd, however, executes 
    --  synchronously with respect to these activities, so can be used 
    --  to cleanup log tables and views that are no longer needed. 
    HREPL.CleanupLogsandViews; 

    -- Mark the last request as PollEnd, and update the Publisher LSN 
    -- to reflect the LSN committed at the publisher. 
    UPDATE HREPL_Publisher 
    SET Publisher_PollInProcess = NoPollInProcess, 
     Publisher_LSN = argLSN; 

    -- Commit transaction 
    COMMIT; 

EXCEPTION 
    WHEN OTHERS THEN 
     ROLLBACK; 
     RAISE; 

END PollEnd; 
+0

आपने देखा होगा कि मैंने कई बार इस जवाब को हटा दिया है और हटा दिया है, लेकिन अब मुझे विश्वास है कि यह काम कर सकता है ... लेकिन अगर यह पहले सुरक्षित वातावरण में थोरौगली टेस्टेट होना चाहिए। –