Dynamodb Secondary Index ProjectionType

Viewed 2505

I have trouble understanding the meaning of the ProjectionType property in DynamoDb's GlobalSecondaryIndex configuration.

For example, if I set it to key, will I only be able to retrieve the key values when querying the table based on the secondary index? Why would that be the case, in my understanding an index would reference a certain row in the database table (from a technical point of view), thus by querying on the index it should be easily possible to retrieve the full datapoint of the index?

What am I missing here?

1 Answers

From what's stated here:

Every secondary index is associated with exactly one table, from which it obtains its data. This is called the base table for the index. When you create an index, you define an alternate key for the index (partition key and sort key). You also define the attributes that you want to be projected, or copied, from the base table into the index. DynamoDB copies these attributes into the index, along with the primary key attributes from the base table. You can then query or scan the index just as you would query or scan a table.

It seems that indexes in DynamoDB are not just pointers / references to items, but a stand-alone self-sufficient storage holding the projected attributes. If it is so, it seems reasonable that when querying the index you are limited to the attributes stored in it.

Related