mustafa.yavuz
mustafa.yavuz

Reputation: 1294

Dynamodb global index query all attributes

If I query with local secondary index, I can retrieve both only projected or all attributes (with an additional latency). However, I can not get all attributes when I query with global secondary index, do we allowed to retrieve only projected attributes?

Upvotes: 3

Views: 3118

Answers (2)

mustafa.yavuz
mustafa.yavuz

Reputation: 1294

I find answer, while creating table explanation is stated in tip. "Projected attributes are attributes stored in the index and can be returned by index queries. Local Secondary Index queries can also return attributes that are not projected by fetching them from the table. Global Secondary Index queries can only return projected attributes. Note that projected attributes incur write and storage costs. For more information and performance tuning tip"

Upvotes: 0

Carlos AG
Carlos AG

Reputation: 1087

When you create your table, you define the properties of your Global secondary index, choosing to project all attributes or only the minumum attributes (hash, range and global).

If you chose to create the global index with the minimum attributes and then you query for all attributes, those extra attributes will not be obtained (this is your case).

The reason:

When you create the global index selecting to project all attributes, Amazon duplicates the extra attributes: attributes in the table and duplicated attributes associated to your global index.

Upvotes: 2

Related Questions