When working with AWS Database Migration Service (DMS) and migrating between PostgreSQL and Oracle, there are key SQL queries you’ll want to use for monitoring, validating, and troubleshooting. Below is a categorized list of useful SQL queries for both PostgreSQL and Oracle, especially tailored to DMS contexts.
🔍 General Categories
-
Schema Comparison
-
Row Count Validation
-
Data Type Check
-
Change Data Capture (CDC) Monitoring
-
Latency and Lag Analysis
-
DMS-specific Tables & Metadata
-
Performance Troubleshooting
📘 PostgreSQL Useful Queries
1. List All Tables
2. Row Count per Table
3. Check Table Size
4. Check Replication/CDC Lag
If logical replication is enabled:
5. Get Indexes for a Table
📕 Oracle Useful Queries
1. List All User Tables
2. Row Count per Table
num_rows
is based on stats — useANALYZE TABLE
orDBMS_STATS.GATHER_TABLE_STATS
for current counts.
3. Actual Row Count
4. Table Size in MB
5. Indexes for a Table
🛠️ DMS Metadata Tables (Query from Target Database)
If DMS is replicating these:
Use these to detect:
-
Apply lag
-
Last replicated change
-
Failed rows or skipped rows
✅ Validation Queries
Compare Row Counts (PostgreSQL vs Oracle)
On PostgreSQL:
On Oracle:
You can automate validation using EXCEPT
logic or checksum approaches.
📈 Monitoring Query Example (DMS Task Monitoring)
Use AWS DMS CloudWatch Logs
and ReplicationInstanceMetrics
to monitor:
-
CDCLatencySource
-
CDCLatencyTarget
-
FullLoadThroughputRowsSource
-
FullLoadThroughputRowsTarget