I have a dynamodb table which contains information of the status of different cron jobs.
Table attributes:
- id [HashKey]
- jobId [RangeKey]
- status ('failed','pending', 'success')
I want to query the items based on the job status
field.
Eg: list all jobs which are in pending
state?
So I created the GSI as below.
GSI:
{
IndexName: 'StatusIndex',
KeySchema: [
{
AttributeName: 'status',
KeyType: 'HASH',
},
],
Projection: {
ProjectionType: 'ALL',
},
},
But the query on GSI is very slow when all the items contains same status
value.
id | jobId | status |
---|---|---|
1 | job1 | pending |
2 | job2 | pending |
3 | job3 | pending |
4 | job4 | pending |
Is this because of not having range key?