1
select * from tableName where columnName="value";

How can I fetch a similar result in DynamoDB using java, without using primary key as my attribute (Need to group data based on a value for a particular column).

I have gone through articles regarding getbatchitems, QuerySpec but all these require me to pass the primary key.

Can someone give a lead here?

1 Answer 1

1

Short answer is you can't. Whenever you use the Query or GetItem operations in DynamoDB you must always supply the table or index primary key.

You have two options:

  1. Perform a Scan operation on the table and filter by columnName="value". However this requires DynamoDB to look at every item in the table so it is likely to be slow and expensive.
  2. Add a Global Secondary Index to your table. This will require you to define a primary key for the index that contains the columnName you want to query
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Yes, I did not want to use 'Scan' for that reason. I will go with the 2nd option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.