PostgreSQL - Performance TuningWhy does PostgreSQL sometimes choose a sequential scan over an index scan even when an index exists?ABecause indexes are only used for sorting, not filteringBBecause the planner estimates that scanning the whole table is faster when many rows matchCBecause PostgreSQL does not support index scans on large tablesDBecause sequential scans always use less memoryCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand planner cost estimationThe planner estimates costs and chooses the fastest method based on row counts and data distribution.Step 2: Recognize when sequential scan is preferredIf many rows match, scanning the whole table can be faster than using an index.Final Answer:Because the planner estimates that scanning the whole table is faster when many rows match -> Option BQuick Check:Planner picks fastest plan based on row estimates [OK]Quick Trick: Planner picks sequential scan if many rows match [OK]Common Mistakes:Thinking indexes are only for sortingBelieving PostgreSQL lacks index scan supportAssuming sequential scans always use less memory
Master "Performance Tuning" in PostgreSQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PostgreSQL Quizzes Advanced PL/pgSQL - Performing operations on cursors - Quiz 7medium Advanced PL/pgSQL - Dynamic SQL with EXECUTE - Quiz 3easy Indexing Strategies - Why indexing strategy matters - Quiz 9hard PL/pgSQL Fundamentals - FOREACH for array iteration - Quiz 1easy Roles and Security - Table-level permissions - Quiz 14medium Transactions and Concurrency - VACUUM and its importance - Quiz 10hard Transactions and Concurrency - Read committed behavior - Quiz 3easy Triggers in PostgreSQL - Trigger function creation - Quiz 15hard Triggers in PostgreSQL - Trigger for audit logging - Quiz 8hard Triggers in PostgreSQL - Trigger for data validation - Quiz 10hard