GetItem on index in `dynamodb-enhanced` dependency
Describe the feature
We need to be able to make a GetItem operation on a "slim" index instead of the main table
Use Case
average size of items in the main table is ~2KB and the average size of items in our GSI is ~100 bytes, that means much less read units consumed.
We can do it by QueryItem and use Stream::findAny but it's less elegant (and maybe slower?)
it will eliminate the current flow:
sdkIterable.stream()
.map(Page::items)
.flatMap(Collection::stream)
.findAny()
With just getting the generic T item (or Optional<T>)
Proposed Solution
add the ability to get a single item from an DynamoDbIndex and update GetItem as it should not be a breaking change, just an optional field addition.
Other Information
No response
Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
AWS Java SDK version used
2.20.157
JDK version used
17
Operating System and version
MacOS 14.4, Ubuntu 22.04
The low-level DynamoDB GetItem only works with primary keys though, it doesn't take an index. So I don't think there's a way to support this in the enhanced client.
You can use QueryEnhancedRequest#AttributesToProject to reduce the number of attributes retrieved.
@debora-ito first of all, can't you make the necessary changes to the low-level GetItem? why does it exists only for the main table?
Second, QueryEnhancedRequest#AttributesToProject doesn't help as it will consume the same read units for the whole item and not for the projected attributes, right?
first of all, can't you make the necessary changes to the low-level GetItem?
Not directly. Each AWS service is the maintainer of their own APIs, what the Java SDK team owns is the DynamoDB Enhanced Client which is built on top of the DynamoDB APIs. I can pass your feature request to the DynamoDB team, and once they release the feature in the GetItem API we can incorporate into the Enhanced Client.
Second, QueryEnhancedRequest#AttributesToProject doesn't help as it will consume the same read units for the whole item and not for the projected attributes, right?
Yup, that is correct, found a note in the Query API reference, quote:
DynamoDB calculates the number of read capacity units consumed based on item size, not on the amount of data that is returned to an application. The number of capacity units consumed will be the same whether you request all of the attributes (the default behavior) or just some of them (using a projection expression). The number will also be the same whether or not you use a FilterExpression.
Didn't know this before I suggested, I apologize.
I'll reach out internally to the DynamoDB team and pass your feature request. Closing this issue in the meantime, as there's no action pending from the Java SDK team.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
Thanks @debora-ito