Want to keep the latest record for each user and delete the other records from the table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
There is one custom table where 10M+ records exist and there are multiple records for each user.
So, want to keep only the latest record for each user and delete the other records from that table.
Solution I am thinking of -
1. Need to get the sys id of latest record per user and store them into an array
2. Then, will export the XML file from the table list with the above getting sys id's which will import after deletion
3. Then will run a scheduled job with limitation to delete the records from that table
4. After that will import the XML into the table again to only store one record per user
As there are 10M+ records exist so it is very tough to fetch the latest records per user.
Can anyone please help with the scripts or suggestions to achieve this? Any other solutions will be fine.
Thanks!