Using the secondary index to improve data access DynamoDB

DynamoDB supports two types of secondary indexes:

  • Secondary index Free Join  - its partitions may sort keys and key partition key and group sort keys on a different index table. Global secondary index is considered "global" because the index query execution across all of the data base tables all partitions.

  • Local secondary index  - the same partition key base table, but different sort key index. local secondary index is the meaning of "local", each partition represents a range of local secondary index is defined as a group will have the same partition key partition table of.

In determining the index type to use, consider the requirements of the application. The following table shows the main differences with the global secondary indexes of local secondary index.

 

feature Global secondary index Local secondary index
Key infrastructure Global two primary key index may be a simple primary key (key partition) or composite keys (and key partition sort keys). local secondary index key must be the primary composite primary key (and key partition sort keys).
Key Properties Partition key index and sort keys (if any) may be a string, numeric or binary type of property any base table. Partitioning key index partition key group table is identical properties. Sort key can be a string, numeric or binary type of property any base table.
Each partition key size limit Global secondary indexes no size limit. For each partition key value, the total size of all index entries must be 10GB or less.
Online Index Operations You can create a Global secondary index when creating tables. You can also add a new global secondary index to an existing table, or delete existing global secondary index. For more information, see Managing Global secondary index . Local secondary index is at the same time creating a table created. You can not add local secondary index to an existing table, you can not delete any existing local secondary index.
Queries and partitions Through the global secondary indexes, queries all partitions across the entire table. With local secondary index, you can query a single partition in the partition key specified in the query.
Read consistency Query the global index supports only two eventual consistency. When the query local secondary index, or you can choose to eventual consistency and strong consistency.
Use pre-throughput Each has its own global secondary indexes for reading and writing a certain pre-set activities. Capacity per occupied queries or scans the index (rather than a base table) global secondary indexes performed. Global secondary index update, too, because it will be written into the table. Read capacity units or query the base table scan will take up the implementation of the local secondary index. When writing to the table, which will update local secondary index; these updates will occupy the base table writing unit of capacity.
Projection property For global inquiries or secondary index scan, you can only ask projected property index. DynamoDB will not acquire any property from the table. If you have a query or scan local secondary index, you can request not projected to property index. DynamoDB automatically extract these properties from the table.

You can create up to 20 global secondary index queries to obtain the highest flexibility for each table (default limit) and up to five local secondary index.

Guess you like

Origin www.cnblogs.com/cloudrivers/p/11620862.html