PostgreSQL - Performance TuningA query uses an index scan but runs very slowly. Which of these could be a cause?AThe table is empty, so index scan has no rows to read.BThe index is on a column with many duplicate values, causing many row lookups.CThe query has no WHERE clause.DPostgreSQL does not support index scans on large tables.Check Answer
Step-by-Step SolutionSolution:Step 1: Analyze index scan performance factorsIf the indexed column has many duplicates, the index scan may fetch many rows, slowing the query.Step 2: Evaluate other optionsEmpty tables run fast; queries without WHERE usually use sequential scan; PostgreSQL supports index scans on large tables.Final Answer:The index is on a column with many duplicate values, causing many row lookups. -> Option BQuick Check:Slow index scan cause = B [OK]Quick Trick: High duplicates in indexed column slow index scans [OK]Common Mistakes:Thinking empty tables cause slow queriesAssuming no WHERE means index scanBelieving PostgreSQL limits index scans by table size
Master "Performance Tuning" in PostgreSQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PostgreSQL Quizzes Advanced PL/pgSQL - Why advanced PL/pgSQL matters - Quiz 7medium Indexing Strategies - Index-only scans mental model - Quiz 8hard PL/pgSQL Fundamentals - Why server-side programming matters - Quiz 10hard PL/pgSQL Fundamentals - DO blocks for anonymous code - Quiz 11easy Performance Tuning - Bitmap index scan behavior - Quiz 12easy Roles and Security - Role creation and management - Quiz 1easy Table Partitioning - Creating partitioned tables - Quiz 7medium Table Partitioning - Creating partitioned tables - Quiz 15hard Table Partitioning - Creating partitioned tables - Quiz 9hard Transactions and Concurrency - Serializable isolation - Quiz 12easy