Posts

Showing posts from April, 2026

Postgres Scan Types in EXPLAIN Plans

Image
  When working with PostgreSQL, understanding query performance is essential. One of the most powerful tools available to developers and DBAs is the   EXPLAIN   command, which shows how a query will be executed. It reveals how tables are accessed, which indexes are used, estimated costs, expected rows, join strategies, and most importantly, the scan types used to retrieve data. For example: EXPLAIN SELECT * FROM employees WHERE salary > 50000 ; Scan types matter because they define how PostgreSQL reads data from tables or indexes. The choice of scan method directly impacts performance using the right scan can make queries significantly faster, while the wrong one can slow things down, especially on large datasets. Types of Scan in PostgreSQL A  Sequential Scan (Seq Scan)  reads the entire table from start to end. PostgreSQL uses it when tables are small, when no suitable index exists, or when a large portion of the table is needed. It is simple and effic...

Point-in-Time Recovery (PITR) vs Snapshot Restore

Image
  In modern database systems, data protection is critical. Accidental deletions, system failures, or corruption can lead to data loss if proper backup strategies are not in place. Two commonly used recovery techniques in  PostgreSQL  are  Point-in-Time Recovery (PITR)  and  Snapshot Restore . Understanding these methods is essential for anyone pursuing  postgresql dba online training . What is Point-in-Time Recovery (PITR)? Point-in-Time Recovery (PITR)  allows you to restore a database to a specific moment in time. It uses continuous backups and transaction logs (Write-Ahead Logs – WAL) to replay changes up to a desired timestamp. How PITR Works Take a base backup Continuously archive WAL files Restore backup and replay logs up to target time PostgreSQL PITR Example A common  postgresql pitr example : Imagine a user accidentally deletes important data at 2:00 PM. With PITR, you can restore the database to 1:59 PM, just before the deletion oc...