Query Plans and Tuning: Reading EXPLAIN
How to find out why a query is slow and fix it: reading EXPLAIN and EXPLAIN ANALYZE, costs, estimated and actual rows, scan and join methods, disk sorts, statistics, misestimates and extended statistics, top-N queries, finding slow queries with pg_stat_statements, and a tuning checklist.
kvi5hnuCode Sprout team member12 min readOn this page
The database doesn't run your SQL as written. A component called the planner (or optimizer) considers many ways of producing the result, such as which index to use, which table to read first and how to join them, estimates the cost of each, and picks the cheapest. The chosen strategy is the query plan.
When a query is slow, the plan tells you why. This article explains how to read plans, the main building blocks you'll meet, why the planner sometimes chooses badly, and a practical process for tuning. Article 55 introduced EXPLAIN for checking index use. This one goes deeper.
The examples use 20,000 generated customers and 200,000 orders, with 90% of orders shipped, 9% pending and 1% cancelled:
CREATE TABLE big_customers (customer_id INTEGER PRIMARY KEY, name TEXT NOT NULL, country TEXT NOT NULL);
CREATE TABLE big_orders (
order_id INTEGER PRIMARY KEY, customer_id INTEGER NOT NULL REFERENCES big_customers,
placed_on DATE NOT NULL, status TEXT NOT NULL, amount NUMERIC(10, 2) NOT NULL
);
CREATE INDEX big_orders_customer_ix ON big_orders (customer_id);
EXPLAIN and EXPLAIN ANALYZE
-- Keep plans simple and repeatable: no parallel workers, statistics from every row
SET max_parallel_workers_per_gather = 0;
SET default_statistics_target = 1000;
CREATE TABLE big_customers (
customer_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
country TEXT NOT NULL
);
INSERT INTO big_customers
SELECT g, 'Customer ' || g, CASE WHEN g % 5 = 0 THEN 'UK' ELSE 'IN' END
FROM generate_series(1, 20000) AS g;
CREATE TABLE big_orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER NOT NULL REFERENCES big_customers,
placed_on DATE NOT NULL,
status TEXT NOT NULL,
amount NUMERIC(10, 2) NOT NULL
);
INSERT INTO big_orders
SELECT g,
(g * 7919) % 20000 + 1,
DATE '2024-01-01' + (g % 1000),
CASE WHEN g % 100 = 0 THEN 'cancelled' WHEN g % 10 = 0 THEN 'pending' ELSE 'shipped' END,
(g % 500) + 0.99
FROM generate_series(1, 200000) AS g;
CREATE INDEX big_orders_customer_ix ON big_orders (customer_id);
ANALYZE big_customers, big_orders;
-- Reading a plan: estimated costs and rows, then what actually happened
EXPLAIN
SELECT c.country, COUNT(*) AS orders, SUM(o.amount) AS revenue
FROM big_orders o
JOIN big_customers c ON c.customer_id = o.customer_id
WHERE o.status = 'pending'
GROUP BY c.country;
EXPLAIN (ANALYZE, TIMING OFF, SUMMARY OFF)
SELECT c.country, COUNT(*) AS orders, SUM(o.amount) AS revenue
FROM big_orders o
JOIN big_customers c ON c.customer_id = o.customer_id
WHERE o.status = 'pending'
GROUP BY c.country;
QUERY PLAN
---------------------------------------------------------------------------------------
HashAggregate (cost=4731.26..4731.29 rows=2 width=43)
Group Key: c.country
-> Hash Join (cost=578.00..4596.26 rows=18000 width=9)
Hash Cond: (o.customer_id = c.customer_id)
-> Seq Scan on big_orders o (cost=0.00..3971.00 rows=18000 width=10)
Filter: (status = 'pending'::text)
-> Hash (cost=328.00..328.00 rows=20000 width=7)
-> Seq Scan on big_customers c (cost=0.00..328.00 rows=20000 width=7)
(8 rows)
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
HashAggregate (cost=4731.26..4731.29 rows=2 width=43) (actual rows=1 loops=1)
Group Key: c.country
Batches: 1 Memory Usage: 24kB
-> Hash Join (cost=578.00..4596.26 rows=18000 width=9) (actual rows=18000 loops=1)
Hash Cond: (o.customer_id = c.customer_id)
-> Seq Scan on big_orders o (cost=0.00..3971.00 rows=18000 width=10) (actual rows=18000 loops=1)
Filter: (status = 'pending'::text)
Rows Removed by Filter: 182000
-> Hash (cost=328.00..328.00 rows=20000 width=7) (actual rows=20000 loops=1)
Buckets: 32768 Batches: 1 Memory Usage: 1038kB
-> Seq Scan on big_customers c (cost=0.00..328.00 rows=20000 width=7) (actual rows=20000 loops=1)
(11 rows)
EXPLAIN shows the chosen plan without running the query. EXPLAIN ANALYZE runs it and adds what actually happened. (TIMING OFF and SUMMARY OFF hide the timings, which vary from run to run. In real work, keep them on.)
A plan is a tree of nodes. Each node produces rows for the node above it:

Read it from the most indented lines outwards, because that's where the rows come from:
Seq Scan on big_ordersreads every order and keeps the pending ones:Rows Removed by Filter: 182000.Seq Scan on big_customersreads all 20,000 customers, andHashbuilds them into an in-memory hash table.Hash Joinlooks up each pending order's customer in the hash table.HashAggregategroups the joined rows by country.
On each line, EXPLAIN gives the planner's estimates:
cost=578.00..4596.26: the estimated cost to produce the first row, then all rows, in arbitrary units based on page reads and CPU work. Costs are for comparing plans, not seconds. A node's cost includes the costs of the nodes below it.rows=18000: the estimated number of rows the node will produce.width=9: the estimated average row size in bytes.
EXPLAIN ANALYZE adds actual rows and loops, the number of times the node ran. actual rows and the times are averages per loop, so a node showing rows=10 loops=3 produced 30 rows in total. With timing on, it also shows the actual time of each node. Comparing estimated with actual rows is the single most useful thing you can do with a plan. Here they match everywhere except the aggregate: the planner expected two countries, but all pending orders happen to belong to Indian customers in this data.
Two cautions. EXPLAIN ANALYZE really runs the statement, so wrap an UPDATE or DELETE in BEGIN ... ROLLBACK when analysing it. And a plan on a small development database can be completely different from production's, because plans depend on table sizes and data distribution. Analyse with realistic data.
Useful options: BUFFERS shows how many pages each node read from memory and from disk (on by default with ANALYZE since PostgreSQL 18), VERBOSE shows output columns, SETTINGS lists non-default settings that affected the plan, and FORMAT JSON produces machine-readable output for visualisation tools.
Scan methods
The leaves of every plan read tables. The main ways (article 55):
| Node | How it reads | Good when |
|---|---|---|
| Seq Scan | every row of the table, in physical order | a large fraction of rows is needed, or the table is small |
| Index Scan | index entries, then each matching row | few rows match, or rows are needed in index order |
| Index Only Scan | the index alone | the index contains every column needed |
| Bitmap Index Scan + Bitmap Heap Scan | collects matching row locations from one or more indexes, then reads the pages in physical order | a moderate number of rows match, or conditions on several indexes are combined |
A sequential scan isn't automatically bad. Reading 200,000 rows sequentially to aggregate them all is the right plan. It's a problem when the query needs a few rows and Rows Removed by Filter is huge.
Join methods
-- Keep plans simple and repeatable: no parallel workers, statistics from every row
SET max_parallel_workers_per_gather = 0;
SET default_statistics_target = 1000;
CREATE TABLE big_customers (
customer_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
country TEXT NOT NULL
);
INSERT INTO big_customers
SELECT g, 'Customer ' || g, CASE WHEN g % 5 = 0 THEN 'UK' ELSE 'IN' END
FROM generate_series(1, 20000) AS g;
CREATE TABLE big_orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER NOT NULL REFERENCES big_customers,
placed_on DATE NOT NULL,
status TEXT NOT NULL,
amount NUMERIC(10, 2) NOT NULL
);
INSERT INTO big_orders
SELECT g,
(g * 7919) % 20000 + 1,
DATE '2024-01-01' + (g % 1000),
CASE WHEN g % 100 = 0 THEN 'cancelled' WHEN g % 10 = 0 THEN 'pending' ELSE 'shipped' END,
(g % 500) + 0.99
FROM generate_series(1, 200000) AS g;
CREATE INDEX big_orders_customer_ix ON big_orders (customer_id);
ANALYZE big_customers, big_orders;
-- Few outer rows: a nested loop with index lookups
EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
SELECT c.name, o.order_id, o.amount
FROM big_customers c
JOIN big_orders o ON o.customer_id = c.customer_id
WHERE c.customer_id BETWEEN 100 AND 102;
-- Both inputs sorted on the join key: a merge join
EXPLAIN (COSTS OFF)
SELECT c.customer_id, o.order_id
FROM big_customers c
JOIN big_orders o ON o.customer_id = c.customer_id
ORDER BY c.customer_id;
QUERY PLAN
--------------------------------------------------------------------------------------
Nested Loop (actual rows=30 loops=1)
-> Index Scan using big_customers_pkey on big_customers c (actual rows=3 loops=1)
Index Cond: ((customer_id >= 100) AND (customer_id <= 102))
-> Bitmap Heap Scan on big_orders o (actual rows=10 loops=3)
Recheck Cond: (c.customer_id = customer_id)
Heap Blocks: exact=30
-> Bitmap Index Scan on big_orders_customer_ix (actual rows=10 loops=3)
Index Cond: (customer_id = c.customer_id)
(8 rows)
QUERY PLAN
-------------------------------------------------------------------
Merge Join
Merge Cond: (c.customer_id = o.customer_id)
-> Index Only Scan using big_customers_pkey on big_customers c
-> Index Scan using big_orders_customer_ix on big_orders o
(4 rows)
The planner has three ways to join two inputs:
- Nested Loop: for each row of the outer input, look up matching rows in the inner input, ideally with an index. For three customers, it finds their 10 orders each with the index on
customer_id:loops=3shows the inner side ran three times. Excellent when the outer input is small. Disastrous when it's large and the inner side has no index. - Hash Join: read the smaller input into a hash table, then scan the larger one and probe the table for each row, as in the first example. Good for large, unsorted inputs joined on equality. Needs memory for the hash table.
- Merge Join: walk through two inputs sorted on the join key, matching as it goes, like merging two sorted lists. Here both inputs come sorted from indexes, and the result is already in
customer_idorder, which theORDER BYneeds anyway.
Which one is best depends on how many rows each side produces, which is why row estimates matter so much: an estimate of 10 outer rows, when there are really 100,000, leads to a nested loop that runs 100,000 index lookups.
Statistics and misestimates
The planner estimates row counts from statistics that ANALYZE collects for each column: the fraction of NULLs, the number of distinct values, the most common values and their frequencies, and a histogram of the rest. Autovacuum runs ANALYZE automatically as tables change, and you can run it yourself after big data loads.
Statistics describe each column separately. When a query filters on two columns, the planner assumes they're independent and multiplies their selectivities. That goes wrong when columns are correlated:
-- Keep plans simple and repeatable: no parallel workers, statistics from every row
SET max_parallel_workers_per_gather = 0;
SET default_statistics_target = 1000;
CREATE TABLE big_customers (
customer_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
country TEXT NOT NULL
);
INSERT INTO big_customers
SELECT g, 'Customer ' || g, CASE WHEN g % 5 = 0 THEN 'UK' ELSE 'IN' END
FROM generate_series(1, 20000) AS g;
CREATE TABLE big_orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER NOT NULL REFERENCES big_customers,
placed_on DATE NOT NULL,
status TEXT NOT NULL,
amount NUMERIC(10, 2) NOT NULL
);
INSERT INTO big_orders
SELECT g,
(g * 7919) % 20000 + 1,
DATE '2024-01-01' + (g % 1000),
CASE WHEN g % 100 = 0 THEN 'cancelled' WHEN g % 10 = 0 THEN 'pending' ELSE 'shipped' END,
(g % 500) + 0.99
FROM generate_series(1, 200000) AS g;
CREATE INDEX big_orders_customer_ix ON big_orders (customer_id);
ANALYZE big_customers, big_orders;
-- Correlated columns fool the planner: in this data, every order placed on
-- 1 Jan 2024 happens to be cancelled, but the planner assumes independence
EXPLAIN (ANALYZE, TIMING OFF, SUMMARY OFF)
SELECT COUNT(*) FROM big_orders
WHERE status = 'cancelled' AND placed_on = DATE '2024-01-01';
SELECT COUNT(*) FILTER (WHERE status = 'cancelled') AS cancelled,
COUNT(*) FILTER (WHERE placed_on = DATE '2024-01-01') AS on_day,
COUNT(*) FILTER (WHERE status = 'cancelled' AND placed_on = DATE '2024-01-01') AS both
FROM big_orders;
-- Extended statistics teach the planner how the two columns relate
CREATE STATISTICS big_orders_status_day (mcv) ON status, placed_on FROM big_orders;
ANALYZE big_orders;
EXPLAIN (ANALYZE, TIMING OFF, SUMMARY OFF)
SELECT COUNT(*) FROM big_orders
WHERE status = 'cancelled' AND placed_on = DATE '2024-01-01';
QUERY PLAN
---------------------------------------------------------------------------------------------
Aggregate (cost=4471.01..4471.02 rows=1 width=8) (actual rows=1 loops=1)
-> Seq Scan on big_orders (cost=0.00..4471.00 rows=2 width=0) (actual rows=200 loops=1)
Filter: ((status = 'cancelled'::text) AND (placed_on = '2024-01-01'::date))
Rows Removed by Filter: 199800
(4 rows)
cancelled | on_day | both
-----------+--------+------
2000 | 200 | 200
(1 row)
QUERY PLAN
-----------------------------------------------------------------------------------------------
Aggregate (cost=4471.50..4471.51 rows=1 width=8) (actual rows=1 loops=1)
-> Seq Scan on big_orders (cost=0.00..4471.00 rows=200 width=0) (actual rows=200 loops=1)
Filter: ((status = 'cancelled'::text) AND (placed_on = '2024-01-01'::date))
Rows Removed by Filter: 199800
(4 rows)
1% of orders are cancelled and 0.1% were placed on 1 January 2024, so the planner estimates 200,000 × 0.01 × 0.001 = 2 rows. But in this data every order from that day was cancelled, so there are 200. A hundredfold underestimate is the kind of error that makes the planner choose a nested loop where a hash join would be far faster, when this condition feeds a join.
CREATE STATISTICS ... ON status, placed_on tells ANALYZE to collect statistics on the combination of columns. After it, the estimate is exactly 200. Kinds of extended statistics: dependencies (one column largely determines another, such as postcode and city), ndistinct (for GROUP BY estimates on several columns) and mcv (most common combinations, used here).
Other common causes of bad estimates:
- Stale statistics after a large load or delete, before autovacuum has caught up. Run
ANALYZE. - Functions and expressions in conditions, such as
WHERE lower(email) = ..., whose selectivity the planner has to guess. An expression index also gives statistics for the expression. - Skewed data beyond the most-common-values list. Raising the column's statistics target with
ALTER TABLE ... ALTER COLUMN ... SET STATISTICS 1000collects more detail. - Parameters in prepared statements, where a generic plan made without knowing the value suits some values poorly (article 59).
Sorts, memory and top-N queries
-- Keep plans simple and repeatable: no parallel workers, statistics from every row
SET max_parallel_workers_per_gather = 0;
SET default_statistics_target = 1000;
CREATE TABLE big_customers (
customer_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
country TEXT NOT NULL
);
INSERT INTO big_customers
SELECT g, 'Customer ' || g, CASE WHEN g % 5 = 0 THEN 'UK' ELSE 'IN' END
FROM generate_series(1, 20000) AS g;
CREATE TABLE big_orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER NOT NULL REFERENCES big_customers,
placed_on DATE NOT NULL,
status TEXT NOT NULL,
amount NUMERIC(10, 2) NOT NULL
);
INSERT INTO big_orders
SELECT g,
(g * 7919) % 20000 + 1,
DATE '2024-01-01' + (g % 1000),
CASE WHEN g % 100 = 0 THEN 'cancelled' WHEN g % 10 = 0 THEN 'pending' ELSE 'shipped' END,
(g % 500) + 0.99
FROM generate_series(1, 200000) AS g;
CREATE INDEX big_orders_customer_ix ON big_orders (customer_id);
ANALYZE big_customers, big_orders;
-- Sorting: in memory when it fits in work_mem, on disk when it doesn't
SET work_mem = '64kB';
EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
SELECT order_id, amount FROM big_orders ORDER BY amount DESC, order_id;
SET work_mem = '32MB';
EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
SELECT order_id, amount FROM big_orders ORDER BY amount DESC, order_id;
-- Top-N: an index on the sort column lets the query stop after 5 rows
CREATE INDEX big_orders_placed_ix ON big_orders (placed_on);
EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
SELECT order_id, placed_on FROM big_orders ORDER BY placed_on DESC LIMIT 5;
QUERY PLAN
-----------------------------------------------------------
Sort (actual rows=200000 loops=1)
Sort Key: amount DESC, order_id
Sort Method: external merge Disk: 4184kB
-> Seq Scan on big_orders (actual rows=200000 loops=1)
(4 rows)
QUERY PLAN
-----------------------------------------------------------
Sort (actual rows=200000 loops=1)
Sort Key: amount DESC, order_id
Sort Method: quicksort Memory: 12395kB
-> Seq Scan on big_orders (actual rows=200000 loops=1)
(4 rows)
QUERY PLAN
--------------------------------------------------------------------------------------------
Limit (actual rows=5 loops=1)
-> Index Scan Backward using big_orders_placed_ix on big_orders (actual rows=5 loops=1)
(2 rows)
Sorts, hash tables and aggregates use memory up to work_mem per operation. When the data doesn't fit, they spill to temporary files:
- With
work_mem = 64kB, sorting 200,000 rows uses an external merge with 4 MB on disk. - With 32 MB, it's a quicksort in memory.
Spilling is much slower than sorting in memory. Look for external merge, Disk:, or hash Batches greater than 1 in plans of slow queries. Raising work_mem for a specific session or query helps, but be careful raising it globally: each sort and hash in each connection can use that much, so 100 connections running complex queries could use many times the setting.
The best sort is one that doesn't happen. With an index on placed_on, ORDER BY placed_on DESC LIMIT 5 reads the index backwards and stops after 5 rows: actual rows=5, instead of sorting 200,000. Top-N queries, "latest orders", "highest scores", should have an index matching their ORDER BY.
Finding the slow queries
Tuning starts with knowing which queries to tune. Look at the whole workload, not just the query someone complained about:
pg_stat_statements, an extension shipped with PostgreSQL, records every distinct query's number of calls, total and mean time, rows and buffer use. Sorting by total time finds the queries that cost the most overall, which is often a fast query called millions of times, not the slowest single query.log_min_duration_statementlogs every statement slower than a threshold, and theauto_explainextension logs their plans automatically, capturing plans of queries that are slow only occasionally.pg_stat_activityshows what's running right now, and what each session is waiting for.
Other databases have equivalents: MySQL's EXPLAIN ANALYZE and slow query log, SQL Server's actual execution plans and Query Store, Oracle's DBMS_XPLAN and AWR reports.
A tuning checklist
When a query is slow:
- Measure it with
EXPLAIN (ANALYZE, BUFFERS)on realistic data. - Find the expensive nodes: the ones with the largest actual time, or that read or remove the most rows.
- Compare estimated and actual rows. Big differences (10× or more) point to statistics problems: run
ANALYZE, add extended statistics, or rewrite conditions the planner can't estimate. - Check access paths. A sequential scan filtering out almost everything wants an index (article 55). An index that isn't used may be defeated by a function, a type mismatch or a leading wildcard.
- Check joins. Nested loops with many outer rows, or missing indexes on join columns, especially foreign keys.
- Check memory. Sorts and hashes spilling to disk.
- Rewrite the query if needed: avoid row-by-row patterns, filter early, replace
ORacross columns withUNION, and avoid the anti-patterns in article 68. - Change one thing at a time, and measure again.
Resist adjusting planner settings globally to force a particular plan, such as enable_seqscan = off. They're useful for experiments, to see what the alternative plan would cost, but not as fixes. PostgreSQL has no built-in query hints. The pg_hint_plan extension adds them, and Oracle, SQL Server and MySQL support hints directly, but fixing estimates and indexes is more robust than forcing plans.
What's current
- PostgreSQL 18 shows
BUFFERSby default inEXPLAIN ANALYZE, reports index searches per node, and adds skip scans for multicolumn B-tree indexes (article 55). - PostgreSQL 17 added
EXPLAIN (SERIALIZE), which measures the cost of converting results for the client, andEXPLAIN (MEMORY)for planner memory use.
Common questions
What's the difference between EXPLAIN and EXPLAIN ANALYZE?
EXPLAIN shows the planned strategy with estimates, without running the query. EXPLAIN ANALYZE runs it and adds actual row counts and times.
What do the cost numbers mean? Estimated startup and total cost in arbitrary units, used to compare alternative plans. They aren't milliseconds.
Why is the planner's row estimate so wrong?
Usually stale statistics, correlated columns, or conditions it can't estimate, such as functions. Run ANALYZE, add extended statistics, or rewrite the condition.
Is a sequential scan always bad? No. It's the fastest way to read a large fraction of a table. It's a problem only when few rows are needed.
How do I find which queries to tune?
Use pg_stat_statements and sort by total time, or log slow statements with log_min_duration_statement and auto_explain.
Summary
- The planner chooses a plan by estimating costs.
EXPLAINshows it, andEXPLAIN ANALYZEruns it and shows what happened. - Read plans from the innermost nodes outwards. Compare estimated rows with actual rows.
- Scans: sequential, index, index-only and bitmap. Joins: nested loop, hash and merge, each best for different sizes.
- Estimates come from per-column statistics. Correlated columns, stale statistics and opaque expressions cause misestimates. Extended statistics help.
- Sorts and hashes spill to disk beyond
work_mem. Indexes matchingORDER BY ... LIMITavoid sorting. - Find expensive queries with
pg_stat_statements, then tune one change at a time.
Practice questions
A plan line reads Seq Scan on big_orders (cost=0.00..3971.00 rows=18000 width=10) (actual rows=18000 loops=1). What do the numbers tell you?
Answer
The planner estimated a startup cost of 0, a total cost of 3971 units, 18,000 output rows of about 10 bytes each. The query actually produced 18,000 rows, and the node ran once. The estimate was accurate.
A nested loop shows (actual rows=12 loops=50000) on its inner index scan, and the outer side was estimated at 50 rows. What happened, and what would you check?
Answer
The outer input produced about 50,000 rows instead of 50, so the inner index scan ran 50,000 times. The planner chose a nested loop because of the misestimate. Check the statistics and conditions on the outer table: run ANALYZE, look for correlated columns or functions in the filter, and consider extended statistics.
A report sorts 5 million rows, and its plan shows Sort Method: external merge Disk: 380000kB. What could you do?
Answer
The sort spills to disk. Raise work_mem for that session or query (SET work_mem = '512MB' before it), reduce the rows or columns being sorted, or add an index matching the ORDER BY if only the first rows are needed.
Why can't EXPLAIN ANALYZE DELETE FROM orders WHERE ... be run casually on production?
Answer
EXPLAIN ANALYZE executes the statement, so the rows are really deleted. Wrap it in BEGIN; ... ROLLBACK; to see the plan and timing without keeping the change.
Previous: Dynamic SQL and Large Objects

More in SQL Course
Quiz: SQL Dialect Differences (PostgreSQL, MySQL, SQL Server, Oracle, SQLite)
Twenty-four questions on how the major SQL databases differ: limiting rows, concatenation, empty strings, identifier case, upserts, identity columns, transactional DDL, error handling, isolation defaults, booleans, set operations, RETURNING, dates and typing.
Quiz: SQL Delicate Details
Twenty-five questions on SQL's subtle corners: NULLs in aggregates, IN and CHECK, sort order of NULLs, rounding, CHAR padding, window frame defaults, identity gaps, LIKE escapes, empty groups, set operations and multi-column updates.
Quiz: SQL Interview Questions
Thirty SQL questions of the kind asked in developer and analyst interviews: WHERE vs HAVING, DELETE vs TRUNCATE, keys, joins, duplicates, Nth-highest values, window functions, ACID, isolation, locking, indexes, views, procedures and performance.
Quiz: SQL Course Final Exam (All 15 Parts)
The final exam for the SQL course: thirty questions across all fifteen parts, from query processing, NULLs, joins and aggregation through windows, data changes, types, design, indexes, security, transactions, procedural SQL and tuning.
Discussion
Sign in to ask a question or share what you learned.