Tablestore can store semi-structured data. When you create a table, you need to only specify one to four primary key columns. Attribute columns are optional.
Each table can contain an unlimited number of attribute columns. Rows in each table can contain different numbers of attribute columns of different data types. When you use an application to write data, you need to specify the names and values of primary key columns and attribute columns.
What is a partition key?
The first primary key column is called the partition key. When the size of data in a table reaches a specific value, Tablestore distributes data to different partitions based on the range of values in the partition key to implement load balancing.
By default, data in a table is distributed to one partition after the table is created. If a table has multiple partitions, data is distributed to a partition based on a specific range of values in the partition key. The range of values in a partition key is sorted by the system based on different data types such as INTEGER and STRING.
The number of partitions affects performance when you access data and the utilization of reserved read/write throughput. When a table contains multiple partitions, the reserved read/write throughput is pre-distributed to each partition based on a proportion.
How do I select an appropriate partition key?
When you create a data table, select a partition key based on the following rules to ensure access performance when the table stores large amounts of data:
Do not use primary key columns whose range of values is narrow, such as the gender Male or Female.
We recommend that you do not use primary key columns whose values may be frequently accessed as the partition key, such as the primary key column that contains timestamps.
We recommend that you use primary key columns that contain data that is less frequently accessed as the partition key. For example, you can select the UserID column.
What do I do if I cannot predict which data will be frequently accessed when I select a partition key?
We recommend that you calculate the hash value of data in a column before you write data to a partition key. For example, when you write a row of data, you can use simple algorithms to calculate the hash value of characters from a user ID, concatenate the hash value and the actual value, and store the concatenation result of the user ID in the table. You can use this lightweight operation to distribute access. Note that a value in a partition key is concatenated by a hash value and actual value. You cannot perform the GetRange operation based on the partition key.
How many data tables can I create in a Tablestore account?
You can create up to 10 instances in each Tablestore account and each instance can contain 64 data tables. In other words, you can create up to 640 tables in a Tablestore account.
The limit can be removed in the following scenarios:
Large amounts of data and high access performance
Unlike traditional SQL-based database services such as MySQL that address access to large amounts of data by using sharding, Tablestore resolves these bottlenecks by implementing a distributed solution.
You can store structured or semi-structured data in a large sparse table without the need to worry about performance issues when the amount of data that you want to access is extremely large.
Rapid business increase
In addition to the increase of data and access requests in your business, you can also use Tablestore to provide services for your customers such as the third-party partners and providers. To provide services for the providers, you can deploy a table for each provider after you activate Tablestore. The number of tables may quickly reach the upper limit. The constant increase of the upper limit can lead to uncontrollable maintenance costs and difficult global data analysis.
In this case, we recommend that you use Tablestore in a nontraditional manner and store large amounts of structured and semi-structured data in a table.
Considerations for Tablestore
When you use Tablestore in distributed mode, the number of tables is considered a resource attribute in Tablestore. When the scale of the Tablestore cluster is specified, Tablestore imposes an upper limit on the maximum number of data tables. However, the scalability of Tablestore allows you to increase the upper limit. Tablestore specifies the upper limit of data tables in an account to facilitate the management of Tablestore resources. For more information, see General limits.
To increase the upper limit of tables in an account, submit a ticket.