Parallel database architectures
Parallel database architectures study how databases split work across multiple CPUs and disks (nodes) to run queries faster and scale; key ideas include shared-everything / shared-nothing / shared-disk designs, measures of speedup and efficiency (Amdahl, Gustafson), and parallel join/aggregation alg
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Parallel database architectures let engineers run large analytic and transaction workloads faster by using many CPUs and disks in parallel. An engineer chooses an architecture and partitioning strategy to meet performance, scalability and cost goals when building data warehouses, OLAP systems, or distributed OLTP clusters.
Key ideas
Start with basic terms (defined before use):
- Node — a single server machine with CPU(s), memory and disk. A node can run a DBMS instance. (unit: one physical or virtual machine.)
- Parallelism — doing multiple operations at the same time. In databases this can be across queries, across data partitions, or across operators inside one query.
- Speed-up — how much faster a parallel system is than a baseline single-node system. Defined exactly below.
- Scale-up — capacity to handle proportionally more data and work when adding resources.
- Shared-everything architecture — an architecture where all CPUs can access all data and storage; typically a single DBMS instance on a tightly-coupled multiprocessor with shared memory and shared disks.
- Shared-nothing architecture — an architecture where each node owns its private CPU, memory and disk; nodes communicate over a network; data is partitioned across nodes.
- Shared-disk architecture — every node has its own CPU and memory but all nodes access a shared disk subsystem; coordination is required to avoid conflicts.
Exact definitions and properties:
- Definition (Speed-up): Speed-up S(p) for p processors is S(p) = T(1) / T(p), where T(1) is execution time on one processor and T(p) on p processors. Assumes same algorithm and problem size.
- Definition (Efficiency): Efficiency E(p) is E(p) = S(p) / p (dimensionless). Efficiency measures resource use per processor.
Important laws (stated exactly):
- Amdahl's Law (strong scaling): If fraction f of a program is perfectly parallelisable and fraction (1 − f) is strictly serial, then the theoretical maximum speed-up with p processors is S(p) = 1 / ((1 − f) + f / p). Assumptions: fixed problem size; parallel portion divides perfectly without overhead; serial portion cannot be parallelised.
- Gustafson's Law (weak scaling): If the parallel portion scales with p, and α is fraction of execution time spent in the serial part on p processors, then scaled speed-up is S(p) = p − α·(p − 1). Assumptions: problem size increases with p; serial time remains constant in absolute time.
Parallel architectures (describe how to draw each):
- Shared-everything: draw one rectangle labelled “machine” with multiple CPUs inside connected to a single shared memory block and a shared disk. Label CPUs, shared memory, and disk. Explain: good for small-scale SMP systems; requires cache-coherence and fine-grained locking; contention on shared resources is a bottleneck.
- Shared-nothing: draw multiple separate boxes (nodes), each with CPU, memory, disk. Connect boxes with a network line. Label network. Explain: scales well horizontally, low contention on I/O, but query processing requires data shipping and distributed coordination.
- Shared-disk: draw multiple nodes each with CPU and memory, all connected to a shared disk network (SAN). Label a lock-manager or coordination service. Explain: middle ground; needs distributed locking for consistency.
Data partitioning strategies (exact definitions):
- Horizontal partitioning (sharding) — split table rows across nodes by a partition function. Each row resides on exactly one node.
- Range partitioning — rows split by value ranges on a key (e.g., id 1–1000 -> node A). Good for range queries but may cause skew.
- Hash partitioning — partition by hash(key) mod p. Good for even distribution and for partitioned joins.
- Round-robin — assign rows in turn to nodes (even distribution but poor locality).
Parallel query processing methods (exact descriptions):
- Inter-query parallelism: run independent queries concurrently (different transactions or sessions) — simplest use of parallelism.
- Intra-query parallelism: split a single query across nodes/CPUs. Two common intra-query methods:
- Partitioned parallelism: each operator instance runs on data partition(s) owned by a node; results are combined.
- Pipelined parallelism: downstream operator consumes tuples as upstream produces them (operator parallelism inside a node or across nodes).
Parallel join algorithms (step-by-step descriptions):
- Partitioned Hash Join (for equijoins, shared-nothing):
- Choose hash function h on join key and p partitions (one per node).
- Each node reads its local fragments of R and S, applies h to each tuple, and sends resulting buckets to the node owning that bucket (data shuffling over network).
- After exchange, node i has local buckets R_i and S_i where all join keys that hash to i reside.
- Node i builds an in-memory hash table on smaller of R_i or S_i and probes with the other to produce matched tuples.
- Collect or stream results. Assumptions: network cost for shuffle, enough memory for build bucket per node.
- Broadcast (or Replicated) Join (when one relation is small):
- Replicate the small relation S to all nodes.
- Each node joins local R fragment with local copy of S. Use when |S| is small enough to fit memory on each node.
Costs and bottlenecks: network bandwidth and latency, disk I/O, skew (uneven partition sizes), synchronization overhead (barriers), and coordination (locks, distributed transactions). Explain trade-offs: shared-nothing reduces lock contention but increases data shipping; shared-everything reduces data shipping but increases contention and coherence traffic.
Formulas
S(p) = T(1) / T(p) — Speed-up; S(p) dimensionless; applies for same problem size.
E(p) = S(p) / p — Efficiency; E(p) dimensionless; measures utilization.
S(p) = 1 / ((1 - f) + f / p) — Amdahl's Law; f is fraction parallelisable (dimensionless); p is number of processors (dimensionless); applies for fixed problem size.
S(p) = p - α·(p - 1) — Gustafson's Law; α is serial fraction on p processors (dimensionless); applies when problem scales with p.
Cost_shuffle ≈ size_sent / bandwidth + messages·latency — Network shuffle cost estimate; size_sent in bytes (SI: B), bandwidth in bytes/s (B·s^-1), latency in seconds (s). Use to estimate data movement overhead.
Worked examples
Numerical Amdahl example (exam-style): Given: single-node execution time T(1) = 100 s. Fraction f = 0.90 is parallelisable. Compute T(8) and speed-up S(8) for p = 8 processors assuming ideal parallelization and no overhead. Step 1: Use Amdahl: S(8) = 1 / ((1 - f) + f / p) = 1 / (0.10 + 0.90 / 8). Step 2: Compute 0.90 / 8 = 0.1125. Sum = 0.10 + 0.1125 = 0.2125. Step 3: S(8) = 1 / 0.2125 = 4.705882... ≈ 4.7059 (dimensionless). Step 4: T(8) = T(1) / S(8) = 100 / 4.705882 = 21.25 s. Final answer: S(8) ≈ 4.7059, T(8) ≈ 21.25 s.
Partitioned hash join trace (algorithm trace): Small input: R = {(1,A),(2,B),(3,C)}; S = {(2,x),(3,y),(4,z)}; p = 2 nodes; hash h(key) = key mod 2. Step 1: Partition/send phase:
- R tuples: key 1 -> h=1 -> node1, (1,A) sent to node1; key2->0->node0; key3->1->node1.
- S tuples: key2->0->node0; key3->1->node1; key4->0->node0. After shuffle, node0 has R0={(2,B)}, S0={(2,x),(4,z)}; node1 has R1={(1,A),(3,C)}, S1={(3,y)}. Step 2: Build and probe per node:
- Node0 builds hash table on R0 (small): table {2 -> (2,B)}. Probe S0: (2,x) matches key2 -> output (2,B,x); (4,z) no match.
- Node1 builds hash table on S1 (or smaller of two): table {3 -> (3,y)}. Probe R1: (1,A) no match; (3,C) matches -> output (3,C,y). Final outputs: (2,B,x) and (3,C,y). Show steps and which node produces each. Bold final outputs: (2,B,x), (3,C,y).
- Model-answer theory question (short essay): "Compare shared-nothing and shared-everything for OLAP workloads." Model answer summary: Define both architectures (as above). Explain that shared-nothing scales linearly for read-heavy OLAP because data is partitioned and most queries can be expressed to run on local partitions or with a single shuffle (partitioned join). Cite bottlenecks: network for shuffle, need for partitioning strategy to avoid skew. Shared-everything easier for transactional workloads requiring fine-grained locking and complex joins without data movement, but suffers from contention and cache-coherence limits as nodes increase. Conclude with when to choose each: choose shared-nothing for large-scale analytical systems (data warehouses), shared-everything for smaller SMP OLTP systems. (Full marks include definitions, architecture diagrams, pros/cons, and concrete performance trade-offs.)
Common mistakes
- Assuming hash partitioning always eliminates data movement; wrong when join keys are not the partitioning key or when skew exists.
- Mixing up shared-disk and shared-everything: shared-disk still has independent nodes (no shared memory) and needs coordination for cache consistency.
- Forgetting to consider skew (hot partitions) which can dominate runtime even if average balance looks good.
For your exam
Question types you will see:
- Definitions and diagrams (explain shared-nothing /-everything /-disk; draw and label architectures).
- Short notes (advantages/disadvantages, where to use each architecture).
- Derivations (derive Amdahl's Law formula; discuss assumptions and limits).
- Numericals (compute speed-up, efficiency; estimate data-shuffle cost using bandwidth/latency).
- Algorithm traces (step-by-step partitioned hash join or broadcast join on small datasets). What full-marks answers include:
- Clear definitions of all bolded terms.
- Exact law formulas with explanation of symbols and assumptions.
- Correct diagrams drawn and labelled as requested.
- For numericals: show formula, substitute numbers, compute stepwise and give units/dimensionless note, final bold answer.
- For algorithm traces: show tuple movement, local builds/probes, and final outputs.
Quick check
- State Amdahl's Law for p processors and explain its assumption in one sentence.
- Name three partitioning strategies for tables and give one pro or con for each.
- For p = 4 and f = 0.75 (fraction parallel), compute S(4) by Amdahl and E(4). Answers: 1) S(p) = 1 / ((1 - f) + f / p); assumption: fixed problem size and perfect parallelisation for fraction f. 2) Range (good for range queries, bad if skew); Hash (good balance, bad for range queries); Round-robin (even distribution, bad locality). 3) S(4) = 1 / (0.25 + 0.75/4) = 1 / (0.25 + 0.1875) = 1 / 0.4375 = 2.2857; E(4) = 2.2857 / 4 = 0.5714 (dimensionless).
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?