Search This Blog

2023/07/05

Horizontal vs Vertical partitioning of table

 Vertical and horizontal partitioning are two techniques used

in database design to improve performance and manageability
of large tables.

Vertical Partitioning:
Vertical partitioning involves splitting a table into multiple
tables by columns. Instead of storing all the columns in a
single table, the table is divided into multiple tables
based on the logical separation of data. Each partition
contains a subset of the columns.
The main advantages of vertical partitioning are:

Reduced storage requirements: By dividing the table into
smaller tables, the overall storage space can be reduced
as each partition only contains the necessary columns.
Improved query performance: Queries that only require a
subset of columns can be executed faster as they only
need to access the relevant partition(s) instead of
scanning the entire table.

Easier maintenance: Vertical partitioning can make it easier
to manage and maintain the database schema, especially when
dealing with tables with a large number of columns.
However, there are some considerations to keep in mind
when using vertical partitioning:

Join operations: If queries frequently involve joining data
from different partitions, it may introduce additional
complexity and overhead.

Data distribution: The partitioning scheme should be carefully chosen
to ensure an even distribution of data across partitions, avoiding
hotspots or imbalances.


Horizontal Partitioning:
Horizontal partitioning involves splitting a table into multiple tables
by rows. Each partition contains a subset of rows that satisfy a certain
condition or range. The partitions can be stored in the same database
or distributed across different databases or servers.
The benefits of horizontal partitioning include:

Improved query performance: Queries that only require data from a
specific partition can be executed faster as the database system
only needs to scan the relevant partition(s) instead of the entire
table.

Scalability: Horizontal partitioning allows for distributing the data
across multiple servers, enabling better scalability and handling of large
datasets.

Simplified maintenance: Partitioning can make it easier to manage and
perform maintenance tasks on subsets of data without affecting the entire
table.
However, there are some considerations to keep in mind when using horizontal
partitioning:

Data distribution: Careful consideration should be given to how the data is
partitioned to ensure even distribution and avoid hotspots or imbalances.
Join operations: Joining data from different partitions can introduce
complexity and potential performance issues.

Indexing: Appropriate indexing strategies should be employed to optimize
query performance within each partition.

Both vertical and horizontal partitioning techniques can be used together
to further improve performance and manageability, depending on the specific
requirements of the database system and the nature of the data being stored.







No comments:

Post a Comment