Intermediate table synchronization scheme (full, incremental)

Source: Internet
Author: User
A big data statistics and analysis system has been developed recently.
Http://www.cnblogs.com/edobnet/archive/2005/04/24/144521.html
Http://edobnet.cnblogs.com/archive/2005/11/11/273947.html

To improve performance, the synchronization of intermediate tables adopts the scheme of full synchronization at the beginning, daily and incremental synchronization.
Let me introduce our incremental solution!
To increment, the incremental log table is required. The design of the incremental log table is as follows.

Key (original business table keyword), create_date (Change Time), flag (data modification and deletion flag), and use_flag (whether the incremental table is used or not, (One bucket is used for filtering ))

Perform the following operations during daily incremental synchronization: -- If the incremental log table has all the flag spaces used, move the incremental log table to the incremental log backup table.
Insert Log_manual_inc_bak
Select   *
From Log_manual_inc
Where   Left (Using_flag, 4 ) = ' 1111 '

Delete Log_manual_inc Where   Left (Using_flag, 4 ) = ' 1111 '

-- Create a temporary intermediate table to facilitate synchronization (the Field content is the same as that of the real table)
Create   Table # Tg_entry (
[ Te_entry_id ]   [ Char ] ( 18 ) Not   Null  
..
)
Go

-- ------------------- Delete unintegrated records from the intermediate table
-- Substring (using_flag,) indicates the flag used for this integration.
  Delete   From Tg_entry Where Tg_entry_id In ( Select Tg_entry_id From Log_manual_inc Where   Substring (Using_flag, 2 , 1 ) <> 1 )

.. Now we can synchronize the data,
... The synchronized data is obtained from the original business table. However, the data range is limited. The incremental table does not perform incremental operations (and the operation type is newly added and modified ).

Add a where condition synchronously,
Where log_manual_inc.arj_mark = 'M' and substring (using_flag, 2, 1) <> 1
The retrieved data is stored in the newly created temporary intermediate table, # tg_entry

After synchronization, do not forget to add more table labels.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.