DISTRIBUTED DATABASE SYSTEMS
Query Processing in Distributed
Databases
A Comprehensive Study
Part I — 10 Points
Introduction
Query processing in a distributed database system refers to the set of procedures used to access,
retrieve, and manipulate data that is physically stored across multiple computers or locations
connected through a network. Unlike traditional centralized databases where all data resides in a
single location, distributed databases partition data across geographically dispersed sites,
introducing a new layer of complexity to query execution.
In a centralized database, the query processor only needs to determine how to retrieve data from
one storage location. In a distributed environment, however, the system must identify which sites
hold the relevant data, determine the most efficient way to access and transfer that data, coordinate
parallel execution across multiple sites, and then combine the partial results into a final, coherent
answer for the user.
This document provides a thorough examination of distributed query processing, covering its
objectives, processing steps, strategies, cost models, optimization techniques, and both the
advantages and challenges associated with this critical component of distributed database
management.
Query Processing in Distributed Databases | Page 1 of 10
1. What is Query Processing?
Query processing is the complete set of activities that transforms a user's high-level SQL query into
an efficient execution plan, and then executes that plan to produce the required result set. In a
centralized system, this involves parsing the query, constructing a logical plan, selecting a physical
plan, and executing it. In a distributed database, each of these activities becomes more
sophisticated because data may be spread across many sites, each with its own hardware and
local DBMS.
Example Query
SELECT *
FROM Patient
WHERE Age > 40;
To process even this simple query in a distributed database, the DBMS must perform the following
steps:
1. Parse and validate the SQL syntax for correctness.
2. Translate the query into relational algebra (e.g., σAge>40(Patient)).
3. Determine which sites hold fragments of the Patient table.
4. Generate multiple candidate execution strategies and pick the optimal one.
5. Execute the subqueries at each relevant site in parallel.
6. Collect and merge partial results from all sites.
7. Return the final consolidated result to the user.
Each of these steps involves coordination between different sites over a network, making
distributed query processing significantly more resource-intensive and complex than its centralized
counterpart. The goal of any well-designed distributed DBMS is to make this complexity invisible to
the end user, presenting a seamless interface regardless of how or where data is stored.
2. Objectives of Distributed Query Processing
The primary objectives of distributed query processing focus on efficiency, transparency, and
scalability. These goals guide the design of every component of the distributed query optimizer and
execution engine.
a) Reduce Communication Cost
Data transfer across a network is far more expensive (in time and resources) than local disk I/O or
CPU operations. Minimizing inter-site data movement is therefore the highest priority in distributed
query optimization. Strategies to achieve this include:
• Performing selection and projection operations locally before transmitting data.
• Using semijoin operations to reduce the size of data shipped between sites.
Query Processing in Distributed Databases | Page 2 of 10
• Sending only the minimal set of attributes needed for the final result.
• Avoiding the transfer of entire tables when only a small fraction of rows is needed.
b) Improve Response Time
Response time is the total elapsed time from when a query is submitted until the final result is
returned to the user. Distributed systems can reduce response time by exploiting parallelism:
• Intra-query parallelism: different subqueries execute simultaneously at multiple sites.
• Pipeline parallelism: partial results from one stage feed immediately into the next stage.
• Independent subqueries that do not share data can execute concurrently, cutting total wait
time.
c) Optimize Resource Usage
Each site in a distributed system has limited CPU, memory, disk I/O, and network bandwidth. The
query optimizer should distribute workload evenly to:
• Prevent any single site from becoming a bottleneck.
• Maximize utilization of available computing resources.
• Avoid unnecessary replication of computation across sites.
d) Maintain Transparency
Users and applications should not need to know how data is fragmented, replicated, or located
across sites. The DBMS achieves this through:
• Fragmentation transparency: users query the whole relation; the system handles fragment
access.
• Location transparency: users do not need to specify the site of the data.
• Replication transparency: the system manages multiple copies automatically.
3. Steps in Distributed Query Processing
Distributed query processing is typically divided into six distinct phases. Each phase transforms the
query into a more concrete and optimized form, until it can be physically executed at the relevant
sites.
Step 1: Query Parsing and Translation
The SQL query submitted by the user is first analyzed by the query parser. This phase checks for
syntactic and semantic correctness, verifies that the referenced tables and columns exist, resolves
ambiguous names, and translates the high-level SQL into an equivalent relational algebra
expression.
Query Processing in Distributed Databases | Page 3 of 10
Example: The query below is parsed and converted into relational algebra:
SELECT Name
FROM Doctor
WHERE Salary > 50000;
This becomes the relational algebra expression: πName(σSalary>50000(Doctor)), which serves as
the starting point for further optimization.
Step 2: Query Decomposition
The global query is broken down into smaller subqueries, each of which can be evaluated using
basic relational algebra operators. This phase includes:
• Normalization: converting the query into a canonical form (e.g., conjunctive normal form).
• Semantic analysis: verifying that the query is semantically valid and can produce a non-
empty result.
• Simplification: removing redundant predicates, flattening nested subqueries, and applying
equivalence rules to reduce complexity.
• Restructuring: reorganizing operations to push selections and projections as close to the
data sources as possible (reducing intermediate result sizes early).
Step 3: Data Localization
Using the global data catalog (also called the data dictionary), the system determines exactly which
sites hold the fragments of each relation referenced in the query. The system must account for:
• Horizontal fragmentation: rows of a table split across sites by a condition (e.g., patients in
Addis Ababa vs. patients in Bahir Dar).
• Vertical fragmentation: columns of a table split across sites.
• Mixed fragmentation: a combination of horizontal and vertical.
• Replication: a relation or fragment may exist at multiple sites for fault tolerance.
For example, in a hospital database:
• Patient records for the Addis Ababa region may be stored at Site 1.
• Patient records for the Bahir Dar region may be stored at Site 2.
• Doctor salary information may reside only at Site 3 (the headquarters).
The localization phase produces a modified query that explicitly references each fragment and its
location, replacing global relation names with their physical fragment counterparts.
Step 4: Global Query Optimization
This is the most critical phase of distributed query processing. The optimizer generates a set of
candidate execution plans for the localized query and selects the one with the lowest estimated
total cost. Key decisions include:
Query Processing in Distributed Databases | Page 4 of 10
• Join ordering: which pairs of relations should be joined first to minimize intermediate result
sizes.
• Join method: nested-loop join, sort-merge join, or hash join, depending on data sizes and
site capabilities.
• Data movement strategy: should data be moved to one site (ship-whole), or should only
qualifying tuples be sent (semijoin approach)?
• Degree of parallelism: which subqueries can be executed concurrently?
The cost model used during global optimization typically considers communication cost (dominant),
CPU cost, I/O cost, and memory usage. The optimizer may use dynamic programming, heuristic
search, or genetic algorithms to explore the plan space.
Step 5: Local Query Optimization
Once the global plan assigns subqueries to specific sites, each site independently optimizes its
assigned subquery using its local query optimizer. Local optimization is similar to query optimization
in a centralized DBMS and may use techniques such as:
• Index selection to avoid full table scans.
• Choosing the best join algorithm based on local statistics.
• Buffer management and I/O scheduling.
Step 6: Query Execution
The final execution phase carries out the physical plan. Each site executes its local subquery and
produces partial results. These are then transmitted to a coordinator site (usually the site that
initiated the query) where they are assembled into the final result. Key characteristics of this phase
include:
• Parallel execution: independent subqueries run simultaneously across sites.
• Pipelining: some results may be streamed as they are produced rather than waiting for full
completion.
• Error handling: if a site fails during execution, the system may retry or return a partial result
depending on the consistency requirements.
4. Query Processing Strategies
There are two fundamental strategies for processing distributed queries: centralized and distributed.
The choice between them depends on data size, network bandwidth, the number of sites involved,
and query complexity.
a) Centralized Strategy
In the centralized strategy, all relevant data from remote sites is transferred to a single processing
site, where the entire query is executed. This approach is straightforward to implement because it
Query Processing in Distributed Databases | Page 5 of 10
leverages an existing local query optimizer, but it can generate enormous network traffic when
dealing with large tables.
Aspect Details
Description All data shipped to one site for processing.
Best for Small tables, low-bandwidth environments, or queries
touching data at only one remote site.
Advantage Simple to implement; leverages existing local optimizer.
Disadvantage Very high communication cost for large datasets; creates a
processing bottleneck.
b) Distributed Strategy
In the distributed strategy, each site processes its own local data first, producing partial results.
Only these smaller intermediate results are then transmitted and combined at a coordinator site.
This approach significantly reduces data transfer volumes and allows parallel execution.
Aspect Details
Description Each site processes its local fragment; partial results are
merged.
Best for Large tables distributed across many sites with selective
queries.
Advantage Lower network traffic; enables parallel processing; better
scalability.
Disadvantage More complex optimization and coordination logic
required.
5. Cost Model for Distributed Query Processing
An accurate cost model is essential for the query optimizer to compare execution plans. In a
distributed setting, the total cost of a query plan is the sum of several components. Unlike
centralized systems where I/O cost often dominates, communication cost is typically the primary
concern in distributed query processing.
Cost Component Definition Relative
Importance
Communication Cost Time and resources required to transfer Very High
data between sites over the network. (dominant
factor)
Query Processing in Distributed Databases | Page 6 of 10
Cost Component Definition Relative
Importance
CPU Cost Processing time at each site for operations Moderate
like joins, sorts, and aggregations.
I/O Cost Disk read and write time at each site. Moderate
Memory Cost Temporary storage needed for Low to
intermediate results and buffers. Moderate
Response Time Total elapsed time from query submission High (user-
to final result delivery. visible)
In practice, the communication cost for transferring n bytes over a network can be modeled as: Cost
= C_init + C_trans * n, where C_init is the connection setup overhead and C_trans is the per-byte
transmission cost. Because C_init is significant, sending many small messages is often more
expensive than sending one larger message.
6. Optimization Techniques
Several specialized techniques have been developed to reduce the cost of distributed query
execution. The three most important are described below.
a) Semijoin Reduction
A semijoin is a technique used to reduce the volume of data transferred between sites during a
distributed join operation. Instead of shipping an entire table to another site, only the join attribute
values (or a small subset of attributes) are sent. The remote site uses these values to filter its local
data, and only the qualifying rows are sent back.
Semijoin steps for joining Relation R at Site 1 with Relation S at Site 2 on attribute A:
8. Project the join attribute A from R: R' = πA(R) — small transfer.
9. Ship R' to Site 2.
10. Compute the semijoin at Site 2: S' = S ⋉ R' (filter S using R').
11. Ship S' back to Site 1 (much smaller than S).
12. Complete the full join at Site 1: Result = R ⋉ S'.
Semijoins are most beneficial when the join attribute has high selectivity (i.e., only a small fraction
of rows in one table match rows in the other). If selectivity is low, the overhead of the additional
semijoin step may outweigh the savings.
Query Processing in Distributed Databases | Page 7 of 10
b) Join Ordering
The order in which multiple relations are joined can dramatically affect performance. Joining two
large tables first produces a large intermediate result, which then has to be joined with further
tables. The optimizer's goal is to find a join order that minimizes the sizes of intermediate results
throughout the entire query.
For example, in a query joining four relations A, B, C, D, there are many possible orderings:
• ((A ⋉ B) ⋉ C) ⋉ D
• (A ⋉ (B ⋉ C)) ⋉ D
• (A ⋉ B) ⋉ (C ⋉ D)
The best ordering depends on estimated cardinalities (number of rows), selectivity of join
predicates, and the physical location of each relation. Dynamic programming is commonly used to
find the optimal ordering for up to around 10 or 12 relations; for larger numbers of joins, heuristic or
greedy approaches are used.
c) Parallel Processing
Distributed systems can naturally exploit parallelism to reduce response time. Three forms of
parallelism are relevant to query processing:
• Inter-query parallelism: multiple independent queries execute simultaneously across sites.
• Intra-query parallelism: a single query is split into subqueries that execute concurrently at
different sites.
• Intra-operator parallelism: a single operator (e.g., a hash join) is partitioned across multiple
processors.
For example, if a query requires aggregating Patient data from 5 regional sites, each site can
compute a local aggregate (e.g., COUNT, SUM) in parallel. These partial aggregates are then
merged at the coordinator site in a single, fast step. This approach reduces the total processing
time proportionally to the number of parallel sites.
7. Advantages of Distributed Query Processing
When implemented correctly, distributed query processing offers substantial benefits over
centralized approaches:
Advantage Explanation
Parallelism & Speed Multiple sites work simultaneously on different parts of a
query, reducing overall response time.
Scalability New sites can be added to handle growing data volumes
without redesigning the entire system.
Query Processing in Distributed Databases | Page 8 of 10
Advantage Explanation
Fault Tolerance If one site fails, queries can often be re-routed to replicated
data at other sites, improving availability.
Load Distribution Processing load is spread across multiple servers,
preventing bottlenecks on a single machine.
Local Autonomy Each site can optimize its own local queries independently,
using its own optimizer and hardware.
Resource Efficiency Workloads are matched to the most appropriate site,
making better use of distributed hardware.
8. Challenges of Distributed Query Processing
Despite its advantages, distributed query processing also presents significant challenges that must
be addressed in system design:
Challenge Description
Optimization Complexity The search space for execution plans grows exponentially
with the number of sites and joins, making optimal plan
selection computationally difficult.
Network Overhead Even with optimization, inter-site communication
introduces latency that is absent in centralized systems.
Data Replication Consistency When the same data exists at multiple sites, keeping
replicas synchronized during concurrent updates is
challenging.
Site Failures A site failure during query execution may leave the system
in an inconsistent state, requiring recovery protocols.
Synchronization Coordinating concurrent access to distributed data
requires distributed locking or timestamp-based
concurrency control.
Heterogeneity Different sites may run different DBMS software, use
different data formats, or have different query languages,
requiring translation layers.
Security Distributing data across networks and sites increases the
attack surface and makes access control more difficult to
enforce uniformly.
Catalog Maintenance The global data catalog must be kept accurate and
consistent as data is reorganized, replicated, or migrated
between sites.
Query Processing in Distributed Databases | Page 9 of 10
Conclusion
Query processing in distributed databases is a sophisticated and multi-stage discipline that extends
the principles of centralized query processing into a networked, multi-site environment. It
encompasses query parsing and decomposition, data localization using a global catalog, global and
local optimization, and parallel execution across distributed sites.
The primary objective is to retrieve data efficiently while minimizing communication cost — the
dominant cost factor in distributed systems — and maximizing response time through parallelism.
Techniques such as semijoin reduction, intelligent join ordering, and parallel subquery execution
are essential tools in achieving these objectives.
While distributed query processing offers compelling advantages in scalability, fault tolerance, and
performance, it also introduces significant challenges in optimization complexity, consistency
management, and system coordination. A well-designed distributed DBMS must balance all of
these considerations, providing users with a seamless and efficient data access experience
regardless of how and where data is physically stored.
As data volumes continue to grow and systems become increasingly distributed — from traditional
multi-site databases to modern cloud-native and edge computing architectures — the principles and
techniques of distributed query processing remain foundational to the design of high-performance
database systems.
Query Processing in Distributed Databases | Page 10 of 10