Sequential Scans
A sequential scan (Seq Scan) happens when Postgres reads every single row in a table to find the records you asked for.
When it's OK vs. NOT OK
- OK: Scanning a table with 100 rows. It's often faster than an index lookup for very small tables.
- NOT OK: Scanning a table with 1,000,000 rows. This causes massive disk IO and CPU load.
How to decide
pgpulse tracks the ratio of index scans to sequential scans. If you see a large table with a high number of sequential scans, it's almost always a sign that an index is missing or isn't being used.
Common Fixes
- Add an Index: The most common solution. Create an index on the columns used in your
WHEREclause. - Add Filters: Ensure you aren't selecting "all rows" when you only need a subset.
- Update Statistics: Sometimes Postgres chooses a seq scan because it thinks the table is smaller than it actually is. Running
ANALYZEcan fix this. - Use Partitions: For massive datasets, partitioning can help Postgres skip entire chunks of data.