Updated on 2025-04-15 GMT+08:00

Creating Indexes

Scenarios

You will create indexes for a table.

Prerequisites

The table you want to create indexes for has been created.

Notes and Constraints

  • A maximum of five local secondary indexes and 20 global secondary indexes can be created for a table.
  • Indexes can only be created during table creation.
  • Duplicate composite primary keys (shard key and sort key) are not allowed for multiple global secondary indexes of a table.
  • Duplicate keys are not allowed in a single global secondary index.
  • A global secondary index cannot have the same shard key as its base table.
  • Duplicate sort keys are not allowed for multiple local secondary indexes of a table.
  • Duplicate keys are not allowed in a single local secondary index.
  • A local secondary index cannot have the same shard key as its base table.
  • A local secondary index cannot have the same sort key as its base table.

Procedure

  1. Log in to the KVS console.
  2. In the navigation pane, choose Stores.
  3. Search for and select a store where you want to create indexes and click Create Table in the Operation column. Or you can click the store name to go to its details page and click Create Table.
  4. Select a billing mode, enter table details, and configure the provisioned read and write throughput (only required for the provisioned billing mode).
  5. In the Secondary Index area, create secondary indexes. KVS allows you to create local and global secondary indexes.

    1. Click Create Local Secondary Index and configure parameters as instructed in Table 1. Confirm the configuration and click OK.
      Figure 1 Local Secondary Indexes

      Table 1 Local secondary index parameters

      Type

      Parameter

      Description

      Create Local Secondary Index

      Name

      Mandatory

      The name of a local secondary index. It must be 1 to 255 characters long. Numbers (0–9), letters (a–z and A–Z), hyphens (-), underscores (_), and periods (.) are allowed. An index name cannot be XPriIndex.

      Sort Key

      Mandatory

      A sort key must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

      Abstract Field

      Optional

      An abstract field in the local secondary index. You can create multiple abstract fields in an index. An abstract field must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

    2. Click Create Global Secondary Index and configure parameters as instructed in Table 2. Confirm the configuration and click OK.
      Figure 2 Global Secondary Indexes

      Table 2 Global secondary index parameters

      Type

      Parameter

      Description

      Create Global Secondary Index

      Name

      Mandatory

      The name of a global secondary index. It must be 1 to 255 characters long. Numbers (0–9), letters (a–z and A–Z), hyphens (-), underscores (_), and periods (.) are allowed. An index name cannot be XPriIndex.

      Shard Key

      Mandatory

      A shard key must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

      Sort Key

      Optional

      A sort key must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

      Read Throughput

      Value range: 1 to 50000 (unit: RCU) This field is only valid in the provisioned billing mode.

      Write Throughput

      Value range: 1 to 50000 (unit: WCU) This field is only valid in the provisioned billing mode.

      Abstract Field

      Optional

      An abstract field in the global secondary index. You can create multiple abstract fields in an index. An abstract field must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

  6. Confirm the configuration and click OK.