(Scenario-Based) A transaction follows the Basic Two-Phase Locking (2PL) protocol.
It has just released a shared lock on Table A. Can it now acquire an exclusive lock on Table
B?
5Multiple Choice
(Calculation) In a database using the Wait-Die scheme for deadlock prevention,
Transaction T1 (Timestamp 10) requests a lock held by Transaction T2 (Timestamp 20).
What happens?
6Multiple Choice
(Code-Tracing) Which of the following SQL statements explicitly requests an
Exclusive Lock on the selected rows, preventing other transactions from even reading
them in most locking-based engines?
7Multiple Choice
(Conceptual) What is the primary benefit of Strict Two-Phase Locking (Strict 2PL)
over Basic 2PL?
8Multiple Choice
(Scenario-Based) An application uses Optimistic Concurrency Control (OCC). A
transaction spends a long time performing calculations in its local buffer. When it finally tries
to commit, it is told that the underlying data has changed, and it must restart. At which
phase did this failure occur?
9Multiple Choice
(Calculation) If there are 3 transactions (T1, T2, T3) executing concurrently, how many
possible Serial Schedules exist?
10Multiple Choice
(Conceptual) The Thomas Write Rule is an optimization of the Basic Timestamp
Ordering protocol. What does it do when a transaction Ti tries to write to a data item that
already has a Write-Timestamp newer than Ti's own timestamp?
11Multiple Choice
(Comparison) In the context of database locking, what is the difference between
Deadlock and Starvation?
12Multiple Choice
(Scenario-Based) A report runs SELECT SUM(salary) FROM Employees.
Halfway through the scan, a concurrent transaction updates an employee's salary that the
report has already scanned, and another employee's salary that the report has not yet
scanned. The final sum is inconsistent. This is an example of:
13Multiple Choice
(Calculation) Which of the following lock requests would be GRANTED if the data
item is currently held under a Shared (S) Lock by another transaction?
14Multiple Choice
(Code-Tracing) A system is using Multi-Version Concurrency Control (MVCC).
When Transaction T1 (starts at Time 10) reads a row that was updated by Transaction T2
(commits at Time 15), what version of the row does T1 see?
15Multiple Choice
(Comparison) When comparing Pessimistic and Optimistic locking, which is more
suitable for a system with high data contention (many users trying to update the same
rows)?
1Multiple Choice
(Scenario-Based) A database server crashes at Time T. The recovery manager
inspects the log and finds the following sequence. Which action should the manager take for
Transactions T1 and T2? • • •
db-recovery-log
[08:00] <T1, Start>
[08:05] <T1, Write, A, 100, 200>
[08:10] <T2, Start>
[08:15] <T1, Commit>
[08:20] <T2, Write, B, 50, 75> - SYSTEM CRASH --
2Multiple Choice
(Code-Tracing) In a database using the Deferred Update (No-Undo/Redo) protocol,
what will be the state of the physical data on disk if a transaction modifies an item but the
system crashes before the COMMIT command is executed?
3Multiple Choice
(Conceptual) The Write-Ahead Logging (WAL) protocol dictates that:
4Multiple Choice
(Calculation) A database performs a Checkpoint every 30 minutes. If the system
crashes 29 minutes after the last checkpoint, which part of the log must the recovery
manager scan?
5Multiple Choice
(Scenario-Based) A data center experiences a catastrophic fire that physically destroys
the primary database hard drives. To recover the data, which of the following is strictly
required?
6Multiple Choice
(Conceptual) Why must the Redo and Undo operations in a recovery algorithm be
Idempotent?
7Multiple Choice
(Comparison) What is the primary difference between a System Crash and an
Aborted Transaction from a recovery perspective?
8Multiple Choice
(Code-Tracing) Consider the following log entry for an Immediate Update protocol:
<T1, X, 50, 100>. During the Undo phase of recovery, what value is written to data
item X?
9Multiple Choice
(Calculation) In the ARIES recovery algorithm, the "Analysis Phase" creates two
tables. What are they?
10Multiple Choice
(Conceptual) What is the purpose of the Log Sequence Number (LSN) in modern
recovery management?
1Multiple Choice
(Scenario-Based) An e-commerce platform's "Product Search" is slow when users filter
by "Category" and "Price". The DBA creates a single index on (category, price). Now,
searches for WHERE category = 'Toys' are fast, but searches for WHERE price =
50.00 are still slow. Why?
2Multiple Choice
(Comparison) Why do modern RDBMS (like MySQL and SQL Server) utilize B+ Trees
instead of standard B-Trees for disk-based indexing?
3Multiple Choice
(Code-Tracing) Analyze the following execution plan output. Why did the database
engine decide to ignore the index on the status column?
4Multiple Choice
(Calculation) A database block is 4KB (4096 bytes). An index entry consists of a 4-byte
integer key and an 8-byte child pointer. Ignoring header overhead, what is the maximum
fan-out (number of children) of an internal node in this B+ Tree?
5Multiple Choice
(Conceptual) Which of the following is the defining characteristic of a Clustered
Index?
6Multiple Choice
(Scenario-Based) A database contains millions of "Sensor Readings". Queries always
look for readings within a specific 10-minute time window (e.g., WHERE reading_time
BETWEEN '10:00' AND '10:10'). Which index type is the most mathematically efficient
for this use case?
7Multiple Choice
(Comparison) What is the main difference between a Dense Index and a Sparse
Index?
8Multiple Choice
(Code-Tracing) You execute the following command to optimize a report. What is the
technical term for the type of index created?
9Multiple Choice
(Calculation) A table is stored as an unordered Heap File with 1,000,000 blocks. If no
index exists, what is the average number of block reads required to find a record by its
Primary Key?
10Multiple Choice
(Conceptual) Why is it often recommended to use a Surrogate Key (like an Auto-
incrementing Integer) as a Clustered Index rather than a natural key (like a UUID or Name)?
sql-shell - optimization
CREATE INDEX idx_report
ON sales(sale_date, region)
INCLUDE (total_amount);
11Multiple Choice
(Scenario-Based) A "User Analytics" table has a membership_type column with
only 3 possible values: 'Free', 'Silver', 'Gold'. Most queries aggregate data based on this
column. Which index type is specifically designed for such "Low-Cardinality" data?
12Multiple Choice
(Calculation) If a B+ Tree index has a height of 3 (Root, 1 Intermediate level, 1 Leaf
level) and the table is NOT clustered, how many I/O operations are required to retrieve a
single row using this index?
13Multiple Choice
(Comparison) What is the primary disadvantage of Static Hashing in a growing
database?
14Multiple Choice
(Conceptual) In indexing theory, what does "Index Selective" refer to?
15Multiple Choice
(Debugging/Analysis) A developer notices that their index on hire_date is not
being used in the following query. What is the cause?
1Multiple Choice
(Conceptual) During the Query Translation phase, into which mathematical
representation is a declarative SQL statement typically converted?
2Multiple Choice
(Scenario-Based) A heuristic-based query optimizer encounters a query joining three
large tables. Which rule is it most likely to apply first to reduce the overall execution time?
3Multiple Choice
(Code-Tracing) Analyze the output of the EXPLAIN command below. What does the
"cost" value (e.g., 0.00..10.50) represent to the optimizer? postgres - plan_analyzer
EXPLAIN SELECT * FROM users WHERE id = 1; - Output:
4Multiple Choice
(Conceptual) In a Cost-Based Optimizer (CBO), where does the engine retrieve the
information needed to estimate the cost of a plan (e.g., number of rows, distinct values)?
5Multiple Choice
(Scenario-Based) A query that was previously fast suddenly becomes extremely slow
after 1 million new rows are inserted into the table, even though an index exists. What is the
most likely cause?
6Multiple Choice
(Comparison) What is the difference between Materialization and Pipelining in the
context of query execution?
7Multiple Choice
(Calculation/Logic) The optimizer is evaluating an INNER JOIN between Table A
(1,000 rows) and Table B (1,000,000 rows). Which join order is it most likely to attempt to
minimize memory usage for a Hash Join?
8Multiple Choice
(Conceptual) Why is the Join Order one of the most complex parts of query
optimization?
21Multiple Choice
Which SQL statement is executed by the query engine first in the logical query processing order?
24Multiple Choice
What will be the result of evaluating: SELECT COUNT(*) FROM Users WHERE bonus = NULL;