Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetItem on index in dynamodb-enhanced dependency #5013

Open
2 tasks
ashr123 opened this issue Mar 12, 2024 · 2 comments
Open
2 tasks

GetItem on index in dynamodb-enhanced dependency #5013

ashr123 opened this issue Mar 12, 2024 · 2 comments
Assignees
Labels
dynamodb-enhanced feature-request A feature should be added or improved.

Comments

@ashr123
Copy link

ashr123 commented Mar 12, 2024

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

@ashr123 ashr123 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Mar 12, 2024
@ashr123 ashr123 changed the title GetItem on index GetItem on index in dynamodb-enhanced dependency Mar 12, 2024
@debora-ito
Copy link
Member

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 debora-ito added closing-soon This issue will close in 4 days unless further comments are made. dynamodb-enhanced and removed needs-triage This issue or PR still needs to be triaged. labels Apr 24, 2024
@debora-ito debora-ito self-assigned this Apr 24, 2024
@ashr123
Copy link
Author

ashr123 commented Apr 25, 2024

@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?

@github-actions github-actions bot removed the closing-soon This issue will close in 4 days unless further comments are made. label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dynamodb-enhanced feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

2 participants