DynamoDB: Range Compared to Global Secondary Index

Say I have a user table with attributes idand timestamp. I would like to be able to request both parameters. If I understand the documentation correctly, there are two ways to do this with DynamoDB:

  • Define the primary key of the hash + range using idboth a hash and timestampas a range.
  • Define a primary key containing only a hash using idand define a global secondary index using timestamp.

What are the advantages and disadvantages of each approach?

+4
source share
2 answers

+ , id .

id - timestamp , , " ".

DynamoDB ( , "john" ?)

id      | timestamp
--------|-------------------------
john    | 2014-04-28T07:53:29.000Z
john    | 2014-04-28T08:53:29.000Z
john    | 2014-04-28T09:53:29.000Z
mary    | 2014-04-28T07:53:29.000Z
jane    | 2014-04-28T07:53:29.000Z

, , + id timestamp , .

, , .

- id, , id . , GSI hash - timestamp, ids, timestamp.

, , , . # 1 - ( id , , , ).

GSI:

  • 5 GSI, , , GSI .
  • GSI , .
  • GSI , , DynamoDB , , - , , - GSI . , , , - GSI .
+7

, .

, id -, . timestamp , , DynamoDB id.

, .

+2

Source: https://habr.com/ru/post/1537942/


All Articles