Recall & Review
beginner
What is a sequential scan in PostgreSQL?
A sequential scan reads every row in a table one by one to find matching rows. It is simple but can be slow for large tables.
Click to reveal answer
beginner
What is an index scan in PostgreSQL?
An index scan uses an index to quickly find rows that match a condition, without reading the whole table. It is faster for selective queries.
Click to reveal answer
intermediate
When does PostgreSQL prefer a sequential scan over an index scan?
PostgreSQL prefers a sequential scan when a large portion of the table needs to be read, because reading the whole table can be faster than using the index.
Click to reveal answer
beginner
How does an index scan improve query performance?
An index scan improves performance by quickly locating only the rows that match the query condition, reducing the number of rows read from the table.
Click to reveal answer
intermediate
What is a downside of using an index scan?
Index scans can be slower if the query matches many rows because it may require many random reads, which are slower than reading sequentially.
Click to reveal answer
What does a sequential scan do in PostgreSQL?
✗ Incorrect
A sequential scan reads every row in the table one by one to find matching rows.
When is an index scan usually faster than a sequential scan?
✗ Incorrect
Index scans are faster when the query matches very few rows because it can quickly locate them using the index.
Why might PostgreSQL choose a sequential scan over an index scan?
✗ Incorrect
PostgreSQL chooses a sequential scan when the query matches a large portion of the table, making it faster to read all rows sequentially.
What is a disadvantage of index scans?
✗ Incorrect
Index scans can be slower if many rows match because they may cause many random disk reads.
Which scan type reads rows in the order they are stored on disk?
✗ Incorrect
Sequential scans read rows in the order they are stored on disk, one after another.
Explain the difference between a sequential scan and an index scan in PostgreSQL.
Think about how each method reads data and when each is faster.
You got /4 concepts.
Describe when PostgreSQL might choose a sequential scan instead of an index scan.
Consider the cost of reading many rows randomly vs sequentially.
You got /4 concepts.