DynamoDB gives us two ways to fetch data: query
and scan
.
The query
operation requires you to specify the primary key. The scan
operation lets you fetch items by specifying any attribute.
Therefore, if you want to fetch data form DynamoDB without using the primary key, you can use the scan operation. However, be careful when using scan
. From the docs:
The Scan operation returns one or more items and item attributes by accessing every item in a table or a secondary index.
The scan
operation can be horribly inefficient if not used carefully. If this access pattern is common in your application, you may want to reorganize your data such that the tagName
is part of the primary key. This will allow you to use the query
operation to fetch the data you need.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…