I have a use case where I am fetching data on certain items (unique itemID) multiple times a day (identified by day_BatchTime) and storing them in DyanmoDB. My composite primary key consists of itemID & day_BatchTime. I have set itemID as partition key and day_BatchTime as the sort key.
But I need to report for each day on a daily basis. So I tried setting up a global secondary index as feedDate. But the query on this is working a bit slow in AWS console. Also, I am getting an error when executing the below query in lambda using Python. Below are the relevant snippets:
response = table.query(KeyConditionExpression=Key('feedDate').eq('18-03-2022'))
"errorMessage": "An error occurred (ValidationException) when calling the Query operation: Query condition missed key schema element: itemID"
The table has about 53,000 items with global secondary index populated for about 31,000 items and I am querying for about 6000 items that are updated in a day. The query execution time appears to much higher compared to what one would normally expect.
Below are my global secondary index details.
- Name: feedDate-index
- Status: Active
- Partition key: feedDate (String)
- Sort key: -
- Read capacity Range: 1 - 10
- Auto scaling at 70%
- Current provisioned units: 1
- Write capacity Range: 1 - 10
- Auto scaling at 70%
- Current provisioned units: 1
- Size 8.9 megabytes, Item count 31,737
Please let me know if I am missing something.