Problem statement: There is address table in Oracle which is having relationship with multiple tables like subscriber, member etc. Currently design is in such a way that when there is any change in associated tables, it increments record version throughout all tables. So new record is added in address table even if same address is already present, resulting into large number of duplicate copies. We need to identify and remove duplicate records, and update foreign keys in associated tables while making sure it doesn't impact the running application.
Tried solution:
- We have written a script for cleanup logic, where unique hash is generated for every address. If calculated hash is already present then it means address is duplicate, where we merge into single address record and update foreign keys in associated tables.
- But the problem is there are around 300 billion records in address table, so this cleanup process is taking lot of time, and it will take several days to complete.
- We have tried to have index for hash column, but process is still taking time.
- Also we have updated the insertion/query logic to use addresses as per new structure (using hash, and without version), in order to take care of incoming requests in production.
- We are planning to do processing in chunks, but it will be very long an on-going activity.
Questions:
- Would like to if any further improvement can be made in above approach
- Will distributed processing will help here? (may be using Hadoop Spark/hive/MR etc.)
- Is there any some sort of tool that can be used here?