Thursday, 12 June 2025

Filled under:

 what should we recommended application team, so that the data they feed in database can be backed up quickly, what are the optimization technqueue to address this, what all things application team to do.

ChatGPT said:

That’s a great initiative, Daidipya — working with the application team to ensure that data design, ingestion, and lifecycle patterns support efficient backups can drastically reduce backup windows and improve recoverability.

Here’s a comprehensive set of recommendations and optimization techniques you can provide to the application team to help make the database easier and faster to back up.


Application Team Recommendations for Backup-Friendly Design


πŸ”Ή 1. Data Segmentation by Time or Lifecycle

πŸ”§ TechniqueπŸ“˜ Recommendation
Partitioning by DateDesign large tables (e.g., logs, transactions) with range partitions (e.g., monthly or yearly). This allows faster backup of active partitions only.
Separate historical dataMove old data to a separate partition or archive table. Ideally, store it in a separate read-only tablespace.

πŸ“ Why: You can skip read-only tablespaces or cold partitions in daily incremental backups.


πŸ”Ή 2. Write Once, Read Many (WORM) Design for Static Data

πŸ”§ TechniqueπŸ“˜ Recommendation
Mark datasets like invoices, audit logs, historical reports as immutable after creation.
Avoid mixing volatile and static data in the same table or tablespace.

πŸ“ Why: Static data can go to a read-only tablespace, which doesn’t need frequent backups.


πŸ”Ή 3. Avoid Unnecessary BLOB / CLOB Storage

πŸ”§ TechniqueπŸ“˜ Recommendation
Store documents/images outside the DB if not queried via SQL. Use references (e.g., file path or object store URL).
If LOBs are mandatory, use SECUREFILE with LOB compression and deduplication. Place them in separate tablespaces.

πŸ“ Why: Reduces database size and LOB overhead in RMAN backups.


πŸ”Ή 4. Compress Cold Data or Low-Access Tables

πŸ”§ TechniqueπŸ“˜ Recommendation
Use OLTP compression or Hybrid Columnar Compression (HCC) for older or low-access tables.
Schedule periodic compression jobs on cold partitions.

πŸ“ Why: Reduces I/O, backup size, and duration significantly.


πŸ”Ή 5. Track Logical Deletes with Flags Instead of Physical Deletes

πŸ”§ TechniqueπŸ“˜ Recommendation
Instead of deleting old rows, mark them with status='DELETED' or move them to an archive partition.

πŸ“ Why: Avoids undo/redo generation, improves backup consistency, and simplifies point-in-time recovery.


πŸ”Ή 6. Modularize Data by Function or Department

πŸ”§ TechniqueπŸ“˜ Recommendation
Separate large modules (e.g., billing, marketing) into different schemas or tablespaces.
Keep fast-changing data isolated from bulk historical data.

πŸ“ Why: Allows module-wise backups, parallel channels, or partial restores.


πŸ”Ή 7. Limit High-Frequency Updates on Wide Tables

πŸ”§ TechniqueπŸ“˜ Recommendation
Avoid frequent updates to large, wide tables. Use separate "status" or "audit" tables for volatile columns.

πŸ“ Why: Frequent updates generate large redo/undo, increasing backup size.


πŸ”Ή 8. Application-Controlled Data Retention & Archival

πŸ”§ TechniqueπŸ“˜ Recommendation
Build logic to automatically archive or purge old data beyond a threshold (e.g., 1 year).
Store archival targets in a dedicated schema/tablespace.

πŸ“ Why: Smaller active dataset = faster backup and faster recovery.


πŸ”Ή 9. Load Data via Batching Instead of Row-by-Row

πŸ”§ TechniqueπŸ“˜ Recommendation
When ingesting data, use batch inserts (e.g., 1000 rows per commit). Avoid single-row insert loops.

πŸ“ Why: Reduces redo/undo generation, lessens RMAN backup strain.


πŸ”Ή 10. Use of IDR or External Staging for Mass Loads

πŸ”§ TechniqueπŸ“˜ Recommendation
For huge loads, use external tables, SQL*Loader, or DBMS_PARALLEL_EXECUTE.
Consider loading to a staging schema first, then merging.

πŸ“ Why: Helps DBA isolate and manage large loads from impacting backup cycles.


πŸ“¦ Summary: What Application Teams Should Do

🧩 Area✅ What They Should Do
Data LifecycleUse partitions, separate static & active data
LOBsCompress, isolate, or externalize them
Cold DataMark or move to read-only tablespaces
Data VolumeAvoid unnecessary retention, archive older data
Load PatternsBatch inserts and reduce row-by-row logic
Storage LayoutAlign modules or high-churn data into separate tablespaces
Maintenance WindowsCoordinate data loads outside backup windows

Would you like me to prepare this as a Confluence-ready checklist or a presentation-style recommendation note for app teams?

You said:
suggest queries to identify unnecessary the BLOB / CLOD Queries to find low access tables , status tables/data which are not often accessed
ChatGPT said:

Here you go, Daidipya — below is a curated list of Oracle queries to identify:

  1. Unnecessary BLOB/CLOB usage

  2. Low-access tables (least used or inactive over time)

  3. Status flag tables / lookup tables that are rarely updated


πŸ“¦ A. Identify Unnecessary or Unoptimized BLOB / CLOB Usage

πŸ” 1. Find All Tables with BLOB or CLOB Columns

sql
SELECT owner, table_name, column_name, data_type FROM dba_tab_columns WHERE data_type IN ('BLOB', 'CLOB', 'NCLOB') ORDER BY owner, table_name;

πŸ” 2. Find LOB Columns That Are NOT SECUREFILE (i.e., BasicFile - less efficient)

sql
SELECT owner, table_name, column_name, securefile, tablespace_name FROM dba_lobs WHERE securefile = 'NO';

πŸ” 3. Find LOB Columns in HOT Tables (with frequent DML)

sql
SELECT l.owner, l.table_name, l.column_name, m.inserts, m.updates, m.deletes FROM dba_lobs l JOIN dba_tab_modifications m ON l.table_name = m.table_name AND l.owner = m.table_owner WHERE (m.inserts + m.updates + m.deletes) > 1000 ORDER BY (m.inserts + m.updates + m.deletes) DESC;

πŸ” 4. Find Large LOB Segments Consuming Space

sql
SELECT owner, segment_name, segment_type, tablespace_name, bytes/1024/1024 AS size_mb FROM dba_segments WHERE segment_type = 'LOBSEGMENT' AND bytes > 100*1024*1024 -- Over 100MB ORDER BY bytes DESC;

πŸ“‰ B. Find Low-Access Tables (Least Used)


πŸ” 1. Least Accessed Tables by Full Table Scan (From v$segment_statistics)

sql
SELECT owner, object_name AS table_name, value AS full_table_scans FROM v$segment_statistics WHERE statistic_name = 'table scans (long tables)' AND object_type = 'TABLE' ORDER BY value ASC FETCH FIRST 50 ROWS ONLY;

You can also query table scans (short tables) if needed.


πŸ” 2. Tables with Minimal DML Activity (From dba_tab_modifications)

sql
SELECT table_owner, table_name, inserts, updates, deletes FROM dba_tab_modifications WHERE (inserts + updates + deletes) < 100 ORDER BY (inserts + updates + deletes) ASC;

πŸ” 3. Tables Not Accessed in Recent AWR Snapshots (If AWR licensed)

sql
SELECT s.owner, s.object_name, ss.logical_reads + ss.physical_reads AS total_io FROM dba_hist_seg_stat ss JOIN dba_objects s ON ss.obj# = s.object_id WHERE ss.snap_id > (SELECT MAX(snap_id) - 30 FROM dba_hist_snapshot) AND s.object_type = 'TABLE' GROUP BY s.owner, s.object_name, ss.logical_reads, ss.physical_reads HAVING (ss.logical_reads + ss.physical_reads) < 100 ORDER BY total_io;

πŸ” 4. Tables Not Queried Recently (From v$sql + v$sql_plan)

sql
SELECT o.owner, o.object_name, COUNT(*) AS query_count FROM v$sql s JOIN v$sql_plan p ON s.sql_id = p.sql_id JOIN dba_objects o ON p.object_name = o.object_name AND o.object_type = 'TABLE' WHERE s.last_active_time > SYSDATE - 30 GROUP BY o.owner, o.object_name ORDER BY query_count ASC;

🧭 C. Identify Status / Lookup Tables (Static Flag Tables)

These tables are usually:

  • Very small in size

  • Have low row count

  • Rarely updated


πŸ” 1. Find Small Tables (Low Row Count, Small Segment Size)

sql
SELECT t.owner, t.table_name, s.bytes/1024/1024 AS size_mb, t.num_rows FROM dba_tables t JOIN dba_segments s ON t.table_name = s.segment_name AND t.owner = s.owner WHERE s.segment_type = 'TABLE' AND t.num_rows < 1000 AND s.bytes < 10*1024*1024 ORDER BY t.num_rows ASC;

πŸ” 2. Find Tables with Very Low or No Updates

sql
SELECT table_owner, table_name, updates FROM dba_tab_modifications WHERE updates < 10 AND inserts < 10 AND deletes < 10 ORDER BY updates;

πŸ” 3. Find Tables Used as Code Lookup or Reference Tables

You can guess based on naming convention and small size:

sql
SELECT owner, table_name FROM dba_tables WHERE table_name LIKE '%STATUS%' OR table_name LIKE '%TYPE%' OR table_name LIKE '%CODE%' OR table_name LIKE '%LOOKUP%' AND num_rows < 1000;

✅ Summary

CategoryUse These ViewsTarget Action
LOB usagedba_lobs, dba_segmentsCompress, move, or redesign
Low-access tablesv$segment_statistics, dba_tab_modifications, dba_hist_seg_statReorg, archive, review
Status/lookup tablesdba_tables, dba_tab_modificationsMove to read-only or shared schema

Would you like to convert this into a shell/SQL script that generates a CSV summary of these categories for easy dashboarding or MS Teams/Confluence reporting?

0 comments:

Post a Comment