I’m excited to share a set of mobile apps I’ve recently completed and published on both the Google Play Store and the Apple App Store. These apps are designed with a simple goal in mind: to make meaningful, structured content more accessible, whether you’re studying theology or improving your English vocabulary. 📱 Now Available on Both Platforms All apps are live and available for download: Google Play Developer Page: https://play.google.com/store/apps/dev?id=5835943159853189043 Apple App Store Developer Page: https://apps.apple.com/ca/developer/q-z-l-corp/id1888794100 📖 Theology & Confession Study Apps For those interested in Reformed theology and classical Christian teachings, I’ve developed a series of apps that present foundational texts in a clean, focused reading format: The Belgic Confession Canons of Dort Heidelberg Catechism Westminster Shorter Catechism Each app is designed to provide a distraction-free experience, making it easier to read, reflect, and revisit these im...
Safe Data Purge: How We Remove Old Records in Large Oracle Tables
- Get link
- X
- Other Apps
By
三好Daddy
-
Safe Data Purge: How We Remove Old Records in Large Oracle Tables
At our company, we periodically purge old data to comply with data retention regulations. Deleting millions of rows from production databases requires careful planning. Here's how we do it.
Step 1: Catalog and Plan
- Catalog all tables and identify retention periods.
- Review retention schedule with legal team.
- Coordinate with other teams to identify downstream dependencies.
Step 2: Backup Tables
Always backup affected tables before deleting. This ensures quick recovery in case of unexpected issues.
Step 3: Understand Table Structure
Identify child tables and parent tables. Delete child tables first to avoid foreign key violations.
Step 4: Batch Deletes vs Direct Deletes
We tested batch deletes in our PT environment and it worked fine. However, in production:
- Tables have 7M+ rows and 1M+ rows to delete
- Batch of 20K rows caused 1.5-hour wait and FK violation
- Automatic rollback occurred
Now we perform incremental deletes:
- Delete 10K rows at a time and commit
- Repeat until all old data is purged
- Slower but more controllable; easier to detect FK violations
Step 5: Sample SQL Playbook
/* ============================================================================
Purpose : Purge old records safely
Strategy : Child tables first, batch deletes, commit per batch, gather stats
============================================================================ */
-- Pre-check counts
SELECT 'child_table_1', COUNT(*)
FROM child_table_1
WHERE created_on < ADD_MONTHS(TRUNC(SYSDATE), -144)
UNION ALL
SELECT 'child_table_2', COUNT(*)
FROM child_table_2
WHERE created_on < ADD_MONTHS(TRUNC(SYSDATE), -144);
-- Direct delete small child tables
DELETE FROM child_table_1
WHERE created_on < ADD_MONTHS(TRUNC(SYSDATE), -144);
COMMIT;
-- Batch delete large tables
DECLARE
v_batch_size CONSTANT PLS_INTEGER := 20000;
v_rows PLS_INTEGER;
v_cutoff_date DATE := ADD_MONTHS(TRUNC(SYSDATE), -144);
BEGIN
LOOP
DELETE FROM large_table
WHERE created_on < v_cutoff_date
AND ROWNUM <= v_batch_size;
v_rows := SQL%ROWCOUNT;
COMMIT;
EXIT WHEN v_rows < v_batch_size;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RAISE;
END;
/
-- Post-check and gather stats
SELECT COUNT(*) FROM large_table WHERE created_on < ADD_MONTHS(TRUNC(SYSDATE), -144);
BEGIN
DBMS_STATS.GATHER_TABLE_STATS(
ownname => 'YOUR_SCHEMA',
tabname => 'large_table',
cascade => TRUE,
estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE
);
END;
/
Key Takeaways
- Use incremental batch deletes for large tables
- Commit frequently to avoid massive rollbacks
- Delete child tables first to respect FK constraints
- Check counts before and after deletion
- Gather statistics after purge to maintain performance
- Consider programmatic purging: As transaction volume grows rapidly, manual batch deletes may become slow again in 6–12 months. Automating purge helps maintain table performance continuously.
❤️ Support This Blog
If this post helped you, you can support my writing with a small donation. Thank you for reading.
batch delete
Code
data purge
database cleanup
DBA
foreign key
incremental delete
large tables
Oracle
SQL playbook
- Get link
- X
- Other Apps
Popular Posts
Swagger annotations for API that allows downloading files as zip
By
三好Daddy
-
I have built out an API that allows you downloading log files as zip in a sprint boot app. The app also integrated with Swagger 3, so I also want this API can be hit in the Swagger UI. In this post, I will demonstrate how to use @ApiOperation annotation to tell Swagger UI download the response as a zip file. use @ApiOperation for your method The key is set media type to "application/octet-stream" which can be recognized by Swagger UI. By doing so, you are set "accept":" application/octet-stream " in the request header. Put below annotation section on top of your API's controller method. @Operation( summary = "", description = "", method="GET", responses = { @ApiResponse(responseCode = "200", description = "", content = { @Content( mediaType = "application/octet-stream" ...
2023, New Start! New AdSense Account! New Earnings!
By
Errong Leng
-
It's been a while after I created adsense account to display ads on this blog. A few years later the payment finally reached my payout threshold, I just found the existed adsense account is bind to China. but I moved to Canada 3 years ago. I tried to change the country of it, but just found Unfortunately it's not possible to change the country of your payment address in AdSense. If you've moved to a new country or territory, you'll need to cancel your existing AdSense account and create a new AdSense account . So I created a new adsense account today on 2023-01-12. Though new account is still under reviewing, I believe it will be approved soon. To reach out payout threshold in this year, I set up the below plan: write one blog per week day!!! write one blog per week day!!! write one blog per week day!!! Try ingress more traffic to this blog
Fix “A problem occurred starting process 'command node'” in Android Studio for React Native
By
Errong Leng
-
Fix “A problem occurred starting process 'command node'” in Android Studio for React Native If you are building a React Native Android project and encounter this error during Gradle sync: A problem occurred evaluating project ':react-native-svg'. > A problem occurred starting process 'command 'node'' —even though node works perfectly in your terminal—this guide will show you how to fix it quickly. Common Misconceptions This error is often mistaken as a Node.js or PATH issue, but that is not always the case. Node.js is installed and working in your terminal. PATH and environment variables appear correct. Still, Android Studio Gradle sync fails with the above error. The Real Cause The issue typically arises because of an incorrect Gradle JDK configuration inside Android Studio . Gradle runs inside a JVM and uses that JVM to spawn external processes (like node ). If the Gradle JDK is incompatible or misconfigured, Gradle will...
Comments
Post a Comment