Skip to main content

How does PostgreSQL choose between various scan types?

Senior PostgreSQL
Quick Answer PostgreSQL scan type selection: SeqScan (scan entire table - good when retrieving large % of rows), IndexScan (index lookup + heap fetch - good for selective queries), IndexOnlyScan (index only, no heap - requires covering index + all-visible pages), BitmapIndexScan + BitmapHeapScan (multiple index conditions combined, efficient for moderate selectivity). Planner chooses based on cost estimates - tune random_page_cost for SSDs.

Answer

The optimizer evaluates selectivity, table size, and cost. Sequential scans are chosen for large portions of tables; bitmap scans help combine multiple indexes.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice