[{"id":"postgresqlbeginner-001","courseId":"postgresql-beginner","domain":"concurrency-mvcc","topic":"MVCC readers and writers","prompt":"A report query reads a large table for ten minutes while the app keeps updating rows in that same table. What does PostgreSQL's MVCC guarantee about the two?","hint":"Consider which kinds of locks conflict with each other.","explain":"PostgreSQL keeps several versions of the data, and each SQL statement works from a snapshot of an earlier state. Think about whether a long read has to queue behind a write, or a write behind a read.","source":"https://www.postgresql.org/docs/current/mvcc-intro.html","interaction":{"type":"single"},"options":[{"id":"a","text":"Reads never block writes, and writes never block reads.","why":"Under MVCC, locks taken for reading do not conflict with locks taken for writing, so neither side waits on the other."},{"id":"b","text":"The report locks the table, so every UPDATE waits until it finishes.","whyNot":"MVCC is designed so that reading does not stop writing; a long report does not make the app's updates wait for it."},{"id":"c","text":"The UPDATEs wait for the report, because a table can only change when no reads are running.","whyNot":"Reads and writes do not queue behind each other under MVCC; the table can change while a read is still in progress."},{"id":"d","text":"The report can see half-finished changes, because MVCC lets reads skip the locks that writes take.","whyNot":"MVCC exists to stop statements from viewing inconsistent data produced by concurrent updates."}],"answer":"a","explanation":"MVCC keeps multiple row versions, so reading never blocks writing and writing never blocks reading.","concept":"MVCC keeps multiple row versions, so reading never blocks writing and writing never blocks reading.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Under MVCC, long reads and writes on the same table do not block each other."]},{"id":"postgresqlbeginner-002","courseId":"postgresql-beginner","domain":"concurrency-mvcc","topic":"Statement-level snapshots","prompt":"Under PostgreSQL's MVCC, each SQL statement sees the latest committed version of every row, so it always reflects the newest data.","hint":"A snapshot is a view of the data taken at an earlier point. Ask whether that is the same as the live rows.","explain":"Each SQL statement in PostgreSQL works from a snapshot, which is one version of the database. The live rows may keep changing, while the snapshot stays a stable view of an earlier state.","source":"https://www.postgresql.org/docs/current/mvcc-intro.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"The statement works from a snapshot of an earlier database version, so it does not always reflect the newest committed data."},{"id":"b","text":"False","why":"Each statement sees a snapshot of the database as it was some time ago, regardless of the current state of the rows."}],"answer":"b","explanation":"Each SQL statement sees a snapshot of the database as it was some time ago, regardless of the current state of the underlying data.","concept":"Each SQL statement sees a snapshot of the database as it was some time ago, regardless of the current state of the underlying data.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["A statement's snapshot is not the same as the live rows at this instant."]},{"id":"postgresqlbeginner-003","courseId":"postgresql-beginner","domain":"concurrency-mvcc","topic":"Default isolation level","prompt":"You start a transaction with BEGIN and never set an isolation level. Which isolation level does PostgreSQL give that transaction by default?","hint":"It is the level most applications run at without changing any setting.","explain":"Each transaction runs at one isolation level, which controls what it can see of other transactions' changes. A transaction can change its level with SET TRANSACTION; if it does not, the server default applies.","source":"https://www.postgresql.org/docs/current/transaction-iso.html","interaction":{"type":"single"},"options":[{"id":"a","text":"Read Committed","why":"Read Committed is the default isolation level in PostgreSQL, so a transaction that sets nothing uses it."},{"id":"b","text":"Repeatable Read","whyNot":"Repeatable Read is stronger than the default, and a transaction has to request it explicitly."},{"id":"c","text":"Serializable","whyNot":"Serializable is the strictest level, and it must be requested explicitly; it is not the default."},{"id":"d","text":"Read Uncommitted","whyNot":"PostgreSQL accepts this name, but it behaves like Read Committed and is not what a bare BEGIN gives you."}],"answer":"a","explanation":"PostgreSQL's default isolation level is Read Committed; Repeatable Read and Serializable must be requested.","concept":"PostgreSQL's default isolation level is Read Committed; Repeatable Read and Serializable must be requested.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Read Committed is the default; stricter levels must be requested explicitly."]},{"id":"postgresqlbeginner-004","courseId":"postgresql-beginner","domain":"concurrency-mvcc","topic":"Read Uncommitted in PostgreSQL","prompt":"In PostgreSQL, a transaction that requests the Read Uncommitted isolation level gets the same behavior as Read Committed.","hint":"Count how many distinct isolation levels PostgreSQL actually implements.","explain":"The SQL standard defines four isolation levels, and each one forbids a different set of anomalies. PostgreSQL accepts all four names, but how it implements each one depends on its MVCC design.","source":"https://www.postgresql.org/docs/current/transaction-iso.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","why":"PostgreSQL implements only three distinct levels, and its Read Uncommitted mode behaves like Read Committed."},{"id":"b","text":"False","whyNot":"Read Committed never shows uncommitted changes, so a Read Uncommitted request in PostgreSQL does not allow dirty reads either."}],"answer":"a","explanation":"PostgreSQL accepts all four standard isolation level names but implements only three; Read Uncommitted behaves like Read Committed.","concept":"PostgreSQL accepts all four standard isolation level names but implements only three; Read Uncommitted behaves like Read Committed.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Requesting Read Uncommitted in PostgreSQL does not allow dirty reads."]},{"id":"postgresqlbeginner-005","courseId":"postgresql-beginner","domain":"concurrency-mvcc","topic":"Serializable isolation level","prompt":"Which TWO statements about the Serializable isolation level in PostgreSQL are true?","hint":"Compare this level with Repeatable Read: what does it add on top?","explain":"Isolation levels trade some concurrency for stronger guarantees. The strictest level can refuse work that looks fine on its own, so the program has to be ready to handle a refusal.","source":"https://www.postgresql.org/docs/current/transaction-iso.html","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"It makes all committed transactions behave as if they ran one after another, in some serial order.","why":"Serializable emulates serial execution for all committed transactions, which is its whole purpose."},{"id":"b","text":"Applications using it must be ready to retry transactions that fail with a serialization failure.","why":"Detecting a conflict that could break serial behavior triggers a serialization failure, so the application must retry."},{"id":"c","text":"A plain SELECT blocks until every writing transaction that touches its table has committed.","whyNot":"Serializable adds monitoring but no blocking beyond Repeatable Read, and reads never block writes under MVCC."},{"id":"d","text":"It is weaker than Repeatable Read, so it lets through more anomalies.","whyNot":"Serializable is the strictest level; it works like Repeatable Read and adds checks for anomalies that Repeatable Read permits."},{"id":"e","text":"It never raises an error, because the server reorders conflicting transactions to avoid them.","whyNot":"Conflicts that could break serial behavior are detected and fail with a serialization error, rather than being quietly reordered."},{"id":"f","text":"It locks every table a transaction reads, so no other transaction can write to those tables.","whyNot":"Serializable adds no table locks of its own; it monitors for conflicts and fails a transaction when one could break serial behavior."}],"answer":"ab","explanation":"Serializable works like Repeatable Read plus conflict monitoring, so committed transactions behave serially; conflicts fail with serialization errors that must be retried.","concept":"Serializable works like Repeatable Read plus conflict monitoring, so committed transactions behave serially; conflicts fail with serialization errors that must be retried.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Serializable adds conflict monitoring, not extra blocking, and failed transactions must be retried."]}]