Skip to main content
Kill -9 Club
Sign in

sequential scan (Seq Scan)

Databases

The plan node that reads every row of a table to keep the ones that match: what EXPLAIN ANALYZE prints as Seq Scan. Seeing one is not a defect to fix. On a small table, or for a query that returns most of the rows, reading everything is the cheapest way to do it, and the planner chose it on purpose. An index is not free: it is updated on every write and it occupies disk. It is justified by an identified query on a large table, not by precaution — an over-indexed table slows down exactly the inserts the application does most often. pg_stat_user_tables says where scans actually accumulate, comparing seq_scan with idx_scan table by table. And before adding anything, compare estimated rows with actual rows: a factor of a hundred between them points at stale statistics, which ANALYZE on the table refreshes.

Also written: Seq Scan, full table scan