5 exercises — practise the English vocabulary for query performance discussions: EXPLAIN scan types, N+1 anti-pattern, query plan cost units, buffer hit rates, and index-only scan terminology.
0 / 26 completed
1 / 26
A senior DBA says in a performance review meeting: "The query is doing a Seq Scan on a 4-million-row table — that's why it's slow." What does Seq Scan mean, and why is an Index Scan preferred for selective queries?
EXPLAIN ANALYZE node type vocabulary:
Option A is the correct definition. A Sequential Scan is not inherently bad — for queries that return a large percentage of rows, it can be faster than an Index Scan because it reads pages sequentially (which is cache-friendly). The problem arises when a Seq Scan occurs on a large table with a highly selective WHERE clause.
Scan type
How it works
Best when
Seq Scan
Reads every page of the table in order
Query returns >10–20% of rows; no suitable index
Index Scan
Traverses the index, then fetches heap pages
Query is selective (<5–10% of rows); index exists
Index Only Scan
Reads only the index; never touches the heap
All projected columns are in the index (covering index)
Bitmap Index Scan
Builds a bitmap of matching heap pages, then reads them
Moderate selectivity; reduces random I/O
How to communicate scan types in reviews:"The planner chose a Seq Scan here because there is no index on the status column and the filter is not selective enough. Adding a partial index on WHERE status = 'pending' would allow an Index Scan and reduce cost significantly."
2 / 26
A code reviewer leaves this comment on a pull request:
"This code has an N+1 problem. We'll issue one query to fetch all posts, then a separate query per post to fetch its author — that's 1 + N queries for N posts."
Which code pattern is the reviewer describing, and what is the standard vocabulary for the solution?
N+1 problem vocabulary:
Option D is the complete and correct description. The N+1 pattern is one of the most common performance anti-patterns in ORM-heavy applications and a standard topic in backend code reviews.
Example — N+1 in code:
// N+1: 1 query for posts, then 1 per post for author
const posts = await Post.findAll(); // 1 query
for (const post of posts) {
const author = await User.findById(post.authorId); // N queries
}
Solution vocabulary:
Term
Meaning
Eager loading
Load associated data up-front, in the same query (JOIN) or a second batched query
Lazy loading
Load associated data on demand as it is accessed — causes N+1
Batched query / DataLoader pattern
Collect all IDs from the loop, then run one IN (...) query to fetch all at once
JOIN fetch
A single query with a JOIN that loads both entities simultaneously
How to phrase the review comment professionally:"This will generate one query per post to load the author relationship — that's N+1. Consider using eager loading (include: ['author']) or a JOIN, which collapses this into a single round trip."
3 / 26
A DBA explains a EXPLAIN output to a junior developer: "The cost estimate shows 8,924.00 — that's the planner's estimate of total cost units, not milliseconds." Which statement correctly explains PostgreSQL's COST value?
PostgreSQL query plan cost vocabulary:
Option B is correct. The COST value in EXPLAIN output is a dimensionless unit, not milliseconds. It is computed from configurable constants that abstract disk I/O and CPU operations.
Key cost constants (postgresql.conf):
Parameter
Default
What it models
seq_page_cost
1.0
Cost of fetching one page via sequential read
random_page_cost
4.0
Cost of fetching one page via random read (index access)
cpu_tuple_cost
0.01
Cost of processing one row
cpu_index_tuple_cost
0.005
Cost of processing one index entry
EXPLAIN output reading vocabulary:
cost=X..Y — X is startup cost (cost before first row returned); Y is total cost
rows=N — planner's estimate of rows returned; compare with actual rows after EXPLAIN ANALYZE
width=N — estimated average row width in bytes
actual time=X..Y — measured execution time in milliseconds (only with ANALYZE)
In performance discussions, always say "cost units" or "estimated cost" — never "the query costs 8,924 milliseconds" when reading plan output without ANALYZE timing.
4 / 26
A DBA reports during a performance review: "The BUFFERS output shows a 98% buffer hit rate — this query is well-cached." What does a buffer hit indicate in the context of a PostgreSQL query plan?
Buffer hit vocabulary in EXPLAIN BUFFERS output:
Option C is correct. PostgreSQL's shared_buffers is an in-memory cache of database disk pages. When a query requires a page, it first checks shared_buffers; if found (a hit), no disk read is needed. If not found (a miss), the page must be fetched from disk (or the OS page cache).
BUFFERS output vocabulary:
Term
Meaning
Buffers: shared hit=N
N pages served from shared_buffers (no disk I/O)
Buffers: shared read=N
N pages read from disk into shared_buffers (disk I/O occurred)
Buffers: shared written=N
N dirty pages flushed to disk by this query
Buffer hit rate
hit / (hit + read) × 100 — higher is better; >90% is generally healthy
How to use buffer hit data in performance discussions:
A low hit rate (e.g., 40%) on a frequently-executed query suggests the working set exceeds shared_buffers — consider increasing it or adding a covering index to reduce the number of pages accessed.
A 100% hit rate does not mean the query is free — CPU processing of many cached pages can still be expensive.
Buffer hits persist across queries; the first cold run of a query will always show more reads than subsequent warm runs.
5 / 26
An architect says in a query review: "We should add a covering index so the planner can use an Index Only Scan instead of an Index Scan." What does an Index Only Scan avoid that a regular Index Scan does not?
Index Only Scan vocabulary:
Option B is the correct definition. A regular Index Scan must make a second I/O round trip from the index entry to the corresponding heap page to fetch the projected columns. An Index Only Scan eliminates this by storing all projected columns directly in the index — called a covering index.
Scan type
Index read?
Heap read?
When possible
Index Scan
Yes
Yes (per row)
Index exists on filter column(s)
Index Only Scan
Yes
No (usually)
Covering index includes all SELECTed columns
Seq Scan
No
Yes (all pages)
No suitable index; high row selectivity
Covering index vocabulary:
Covering index — an index that includes all columns needed to satisfy a query, enabling Index Only Scan
INCLUDE clause — PostgreSQL 11+ syntax to add non-key columns to the index leaf pages: CREATE INDEX idx ON orders (status) INCLUDE (total, created_at)
Heap fetch — the secondary I/O step where a regular Index Scan reads the actual table page to retrieve projected columns not in the index
Visibility map — PostgreSQL checks the visibility map before doing an Index Only Scan; if not all pages are marked all-visible, heap fetches occur anyway
6 / 26
John from the backend team sent this Slack message during a code review:
'I've optimized the query to use `JOIN` instead of subqueries. The old version was returning approximately 15 seconds for this report, and now it's consistently under 2 seconds.'
What is John primarily referring to when discussing optimization? Consider the likely performance bottleneck he identified.
John is discussing the *execution plan* – this is what the database's query optimizer generates to determine the most efficient way to execute the SQL. While indexes can certainly help, and a reduced row count is always beneficial, his comment focuses on the overarching strategy of how the database *processes* the data, which directly impacts performance. A poor execution plan will often lead to slow queries regardless of indexing or row count.
7 / 26
During a code review discussion, Sarah from the frontend team says to David, a backend developer: 'This query is taking forever! It's scanning the entire `users` table. Can we add an index?' David replies, 'I looked at the execution plan and it's doing a full table scan – that's what I expected given the lack of an index on the `email` column.' What does David *specifically* mean by 'full table scan,' and why is this generally considered a performance issue?
David's point about a 'full table scan' refers to the database reading every row in the `users` table sequentially. This is inefficient because it doesn't leverage indexes for fast lookups. A full table scan is particularly problematic when querying a large table like this one, as it creates a significant bottleneck. The key issue here is that the query isn't using an index on the `email` column to narrow down the search; instead, it's examining every record.
8 / 26
During a discussion about query performance with a senior engineer, Mark states: 'The query is performing a full table scan on the `orders` table. This is unacceptable – we need to drastically improve its speed.' Mark's statement highlights a key problem. Considering typical database optimization techniques, what *specifically* does Mark likely mean by 'full table scan,' and why is it problematic in this scenario?
Mark's use of 'full table scan' refers to a database operation where every row in a table is examined. This is problematic because it often requires scanning the entire table, which can be extremely slow, especially for large tables. A full table scan indicates that the query optimizer didn't find any suitable indexes or filtering conditions to narrow down the search, forcing it to consider all rows – this is significantly less efficient than using an index to locate relevant data quickly.
9 / 26
During a Slack conversation about slow query performance, Alex from the analytics team sends this message: 'The query is returning all rows from the `transactions` table. It's taking ages! I think we need to look at adding an index.' What does Alex *specifically* mean by 'returning all rows' in the context of a SQL query? Consider what might be causing such a broad result set.
Alex is referring to a full table scan, where the database examines every row in the `transactions` table to satisfy the query's requirements. This happens when the query's `WHERE` clause doesn't effectively filter rows, leading to an unoptimized retrieval of the entire dataset. A key misconception here is thinking 'returning all rows' means simply a large result set; it specifically indicates the database isn't using any filtering criteria and thus accessing the whole table.
10 / 26
John from the backend team sent this Slack message during a code review:
'I've optimized the query to use `JOIN` instead of subqueries. The old version was returning approximately 15 seconds for this report, and now it's consistently under 2 seconds.'
What is John primarily referring to when discussing optimization? Consider the likely performance bottleneck he identified.
John is discussing the *execution plan* – this is what the database's query optimizer generates to determine the most efficient way to execute the SQL. While indexes can certainly help, and a reduced row count is always beneficial, his comment focuses on the overarching strategy of how the database *processes* the data, which directly impacts performance. A poor execution plan will often lead to slow queries regardless of indexing or row count.
11 / 26
During a code review discussion, Sarah from the frontend team says to David, a backend developer: 'This query is taking forever! It's scanning the entire `users` table. Can we add an index?' David replies, 'I looked at the execution plan and it's doing a full table scan – that's what I expected given the lack of an index on the `email` column.' What does David *specifically* mean by 'full table scan,' and why is this generally considered a performance issue?
David's point about a 'full table scan' refers to the database reading every row in the `users` table sequentially. This is inefficient because it doesn't leverage indexes for fast lookups. A full table scan is particularly problematic when querying a large table like this one, as it creates a significant bottleneck. The key issue here is that the query isn't using an index on the `email` column to narrow down the search; instead, it's examining every record.
12 / 26
During a discussion about query performance with a senior engineer, Mark states: 'The query is performing a full table scan on the `orders` table. This is unacceptable – we need to drastically improve its speed.' Mark's statement highlights a key problem. Considering typical database optimization techniques, what *specifically* does Mark likely mean by 'full table scan,' and why is it problematic in this scenario?
Mark's use of 'full table scan' refers to a database operation where every row in a table is examined. This is problematic because it often requires scanning the entire table, which can be extremely slow, especially for large tables. A full table scan indicates that the query optimizer didn't find any suitable indexes or filtering conditions to narrow down the search, forcing it to consider all rows – this is significantly less efficient than using an index to locate relevant data quickly.
13 / 26
During a Slack conversation about slow query performance, Alex from the analytics team sends this message: 'The query is returning all rows from the `transactions` table. It's taking ages! I think we need to look at adding an index.' What does Alex *specifically* mean by 'returning all rows' in the context of a SQL query? Consider what might be causing such a broad result set.
Alex is referring to a full table scan, where the database examines every row in the `transactions` table to satisfy the query's requirements. This happens when the query's `WHERE` clause doesn't effectively filter rows, leading to an unoptimized retrieval of the entire dataset. A key misconception here is thinking 'returning all rows' means simply a large result set; it specifically indicates the database isn't using any filtering criteria and thus accessing the whole table.
14 / 26
John from the backend team sent this Slack message during a code review:
'I've optimized the query to use `JOIN` instead of subqueries. The old version was returning approximately 15 seconds for this report, and now it's consistently under 2 seconds.'
What is John primarily referring to when discussing optimization? Consider the likely performance bottleneck he identified.
John is discussing the *execution plan* – this is what the database's query optimizer generates to determine the most efficient way to execute the SQL. While indexes can certainly help, and a reduced row count is always beneficial, his comment focuses on the overarching strategy of how the database *processes* the data, which directly impacts performance. A poor execution plan will often lead to slow queries regardless of indexing or row count.
15 / 26
During a code review discussion, Sarah from the frontend team says to David, a backend developer: 'This query is taking forever! It's scanning the entire `users` table. Can we add an index?' David replies, 'I looked at the execution plan and it's doing a full table scan – that's what I expected given the lack of an index on the `email` column.' What does David *specifically* mean by 'full table scan,' and why is this generally considered a performance issue?
David's point about a 'full table scan' refers to the database reading every row in the `users` table sequentially. This is inefficient because it doesn't leverage indexes for fast lookups. A full table scan is particularly problematic when querying a large table like this one, as it creates a significant bottleneck. The key issue here is that the query isn't using an index on the `email` column to narrow down the search; instead, it's examining every record.
16 / 26
During a discussion about query performance with a senior engineer, Mark states: 'The query is performing a full table scan on the `orders` table. This is unacceptable – we need to drastically improve its speed.' Mark's statement highlights a key problem. Considering typical database optimization techniques, what *specifically* does Mark likely mean by 'full table scan,' and why is it problematic in this scenario?
Mark's use of 'full table scan' refers to a database operation where every row in a table is examined. This is problematic because it often requires scanning the entire table, which can be extremely slow, especially for large tables. A full table scan indicates that the query optimizer didn't find any suitable indexes or filtering conditions to narrow down the search, forcing it to consider all rows – this is significantly less efficient than using an index to locate relevant data quickly.
17 / 26
During a Slack conversation about slow query performance, Alex from the analytics team sends this message: 'The query is returning all rows from the `transactions` table. It's taking ages! I think we need to look at adding an index.' What does Alex *specifically* mean by 'returning all rows' in the context of a SQL query? Consider what might be causing such a broad result set.
Alex is referring to a full table scan, where the database examines every row in the `transactions` table to satisfy the query's requirements. This happens when the query's `WHERE` clause doesn't effectively filter rows, leading to an unoptimized retrieval of the entire dataset. A key misconception here is thinking 'returning all rows' means simply a large result set; it specifically indicates the database isn't using any filtering criteria and thus accessing the whole table.
18 / 26
John from the backend team sent this Slack message during a code review:
'I've optimized the query to use `JOIN` instead of subqueries. The old version was returning approximately 15 seconds for this report, and now it's consistently under 2 seconds.'
What is John primarily referring to when discussing optimization? Consider the likely performance bottleneck he identified.
John is discussing the *execution plan* – this is what the database's query optimizer generates to determine the most efficient way to execute the SQL. While indexes can certainly help, and a reduced row count is always beneficial, his comment focuses on the overarching strategy of how the database *processes* the data, which directly impacts performance. A poor execution plan will often lead to slow queries regardless of indexing or row count.
19 / 26
During a code review discussion, Sarah from the frontend team says to David, a backend developer: 'This query is taking forever! It's scanning the entire `users` table. Can we add an index?' David replies, 'I looked at the execution plan and it's doing a full table scan – that's what I expected given the lack of an index on the `email` column.' What does David *specifically* mean by 'full table scan,' and why is this generally considered a performance issue?
David's point about a 'full table scan' refers to the database reading every row in the `users` table sequentially. This is inefficient because it doesn't leverage indexes for fast lookups. A full table scan is particularly problematic when querying a large table like this one, as it creates a significant bottleneck. The key issue here is that the query isn't using an index on the `email` column to narrow down the search; instead, it's examining every record.
20 / 26
During a discussion about query performance with a senior engineer, Mark states: 'The query is performing a full table scan on the `orders` table. This is unacceptable – we need to drastically improve its speed.' Mark's statement highlights a key problem. Considering typical database optimization techniques, what *specifically* does Mark likely mean by 'full table scan,' and why is it problematic in this scenario?
Mark's use of 'full table scan' refers to a database operation where every row in a table is examined. This is problematic because it often requires scanning the entire table, which can be extremely slow, especially for large tables. A full table scan indicates that the query optimizer didn't find any suitable indexes or filtering conditions to narrow down the search, forcing it to consider all rows – this is significantly less efficient than using an index to locate relevant data quickly.
21 / 26
During a Slack conversation about slow query performance, Alex from the analytics team sends this message: 'The query is returning all rows from the `transactions` table. It's taking ages! I think we need to look at adding an index.' What does Alex *specifically* mean by 'returning all rows' in the context of a SQL query? Consider what might be causing such a broad result set.
Alex is referring to a full table scan, where the database examines every row in the `transactions` table to satisfy the query's requirements. This happens when the query's `WHERE` clause doesn't effectively filter rows, leading to an unoptimized retrieval of the entire dataset. A key misconception here is thinking 'returning all rows' means simply a large result set; it specifically indicates the database isn't using any filtering criteria and thus accessing the whole table.
22 / 26
In a code review comment, Elena, the QA engineer, writes to Ben, the database developer: 'This query is consistently blocking the reporting server. The `WHERE` clause seems to be filtering on a column with no index defined. Could we explore adding an index or rewriting it?' Which of the following best captures Elena's concern and suggests a logical next step?
Elena highlights the potential issue of a missing index impacting query speed. Option 1 directly addresses her concern by suggesting investigation based on the identified symptom (blocking server). Options 2 is the most accurate reflection of her request for an examination of indexing, and options 3 & 4 are irrelevant and demonstrate a misunderstanding of performance optimization in databases.
23 / 26
During a Slack discussion about slow query times, Liam from the DevOps team sends this message: 'The query against the `product_reviews` table is taking over 30 seconds to run during peak hours. The database logs show it's doing a full scan of the entire table. I've suggested monitoring its execution plan.' What does Liam *primarily* mean by suggesting monitoring the 'execution plan'?
The execution plan provides a detailed breakdown of how the database engine is carrying out the query. This allows developers to pinpoint issues like full table scans, missing indexes, or inefficient join strategies – it's about understanding *how* the database is executing, not just the raw time.
24 / 26
In a pull request description for a query optimization change, David writes: 'This update replaces the original subquery with a JOIN operation. The initial version was returning approximately 60 seconds for this report; now it's consistently under 10 seconds. The new query utilizes an index on `customer_id`.' What is David *most* emphasizing in his description?
David is focusing on *why* the performance improved – the index. While he mentions the time reduction, the core point is that indexing is a fundamental technique for optimizing query speeds. Option 3 is a consequence but not the primary emphasis.
25 / 26
During a daily stand-up update, Maria from the data engineering team says: 'I've been tackling slow query performance in the `order_details` table. The initial queries were performing full scans and taking up to 5 minutes to execute. I've added an index on the `order_id` column, and the average execution time has reduced to under 30 seconds.' What is Maria primarily communicating about her work?
Maria's update focuses on a targeted solution - adding an index. This is a common approach to resolving slow queries involving full table scans, illustrating the principle of indexing for performance optimization. The other options describe broader, less specific activities.
26 / 26
Sarah from the development team sends a message to Mark, the database administrator: 'The query against the `inventory` table is returning all rows and taking over an hour to complete. It seems like it's doing a full table scan. I suspect there might be a problem with our data model.' What does Sarah *primarily* imply when she says 'problem with our data model'?
Sarah's comment suggests the root cause isn't just the query itself but potentially how the data model is structured. A full table scan often indicates a lack of suitable indexes or constraints that would allow the database to efficiently filter the data – this hints at a broader schema issue.
What does the "Query Optimization Discussion" exercise practise?
Practice English for query optimization discussions: Seq Scan vs Index Scan, N+1 problem vocabulary, EXPLAIN ANALYZE cost units, buffer hit rates, and covering index terminology. 5 advanced exercises.
How many questions are in this exercise?
This exercise has 26 questions, each multiple-choice with a full explanation shown after you answer.
What English level is this exercise for?
This exercise is tagged Advanced. If the vocabulary feels difficult, browse the Database & SQL category page for an easier module to start with.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is free with no account, sign-up, or paywall.
Do I get feedback if I answer incorrectly?
Yes — whichever option you choose, right or wrong, you'll immediately see an explanation clarifying the correct term and why the other options don't fit.
Can I retry this exercise?
Yes — once you finish all the questions, a "Try again" button on the results screen resets the exercise so you can practise as many times as you like.
Do I need an account to track my progress?
No account is required. Your progress bar and score for this session are tracked in the browser as you go, but nothing is saved once you leave the page.
Is "Query Optimization Discussion" part of a larger series?
Yes — it's one exercise in the Database & SQL category on CoderSlingo. See the category page for the full list of related exercises on similar terminology.
Can I link directly to this exercise?
Yes — this exercise has its own permanent URL, so you can bookmark it or share the link directly with a colleague or study partner.
Where can I find more exercises like this one?
See the Database & SQL category page for related exercises, or browse the main Exercises hub for other IT English topics.