what is partitioning the database tables

1、what is partitioning the database tables?什麼是數據庫表分區呢?

就是對數據庫表裏面的數據,按照必定的方式,進行邏輯上或者物理上分開。數據庫

This section discusses how to partition a database to maximize throughput, using the flight reservation casestudy as an example. To partition a table, you choose a column of the table that VoltDB can use to uniquely identify and distribute the rows into partitions. app

The goal of partitioning a database table is to ensure that the most frequent transactions on the table execute in the same partition as the data accessed. ide

總結:ui

經過對上面文字的理解,知道分區不必定是分在主鍵上面,可是確實是常常被使用的列上面。分區我的理解就像是一個類同樣,將一批有獨特的行數據,分配到一片區域上面,而不僅是一行數據。分區的目的是每個數據庫執行事務都在同一片區域上面進行。this

We call this a single-partitioned transaction. Thus the stored procedure must uniquely identify a row by the partitioning column value. This is particularly important for queries that modify the data, such as INSERT, UPDATE,and DELETE statements.spa

 

2、分表的原則

4.4.3. Design Rules for Partitioning Tables
The following are the rules to keep in mind when choosing a column by which to partition table rows:orm


• There can be only one partition column per table. If you need to partition a table on two columns(for example first and last name), add an additional column (fullname) that combines the values of the two columns and use this new column to partition the table.事務

每一張表只有一個分區而且只分在一列上面。ci


• If the table has a primary key, the partitioning column must be included in the primary key.get

若是一張表有主鍵,那麼分區列必定要分在主鍵上面。


• Any integer or string column can identify the partition. VoltDB can partition rows on any column that is an integer (TINYINT, SMALLINT, INTEGER, or BIGINT) or string (VARCHAR) datatype.
(See also Table A.1, 「Supported SQL Datatypes」.)

不過表的字段類型是什麼類型,均可以做爲分區。


• Partition column values cannot be null. The partition columns do not need to have unique values, but you must specify NOT NULL in the schema for the partition column. Numeric fields can be zero and string or character fields can be empty, but the column cannot contain a null value.

分區的列不能爲空。

其它的一些建議。
The following are some additional recommendations:
• Choose a column with a reasonable distribution of values so that rows of data will be evenly partitioned.


• Choose a column that maximizes use of single-partitioned stored procedures. If one procedure uses column A to lookup data and two procedures use column B to lookup data, partition on column B. The goal of partitioning is to make the most frequent transactions single-partitioned.


• If you partition more than one table on the same column attribute, VoltDB will partition them together.

2.1關因而否複製表

對於一些經常使用的 read次數 比較多的表,最好讓其在每一個節點都可以複製一份。在VoltDB裏面,不顯示分區,就會默認複製。

Specifying Replicated Tables


In VoltDB, you do not explicitly state that a table is replicated. If you do not specify a partitioning column in the database schema, the table will by default be replicated.
So, in our flight reservation example, there is no explicit action required to replicate the Flight table.


However, it is very important to specify partitioning information for tables that you want to partition.

If not, they will be replicated by default, significantly changing the performance characteristics of your application.

相關文章
相關標籤/搜索