I am trying to get a largest value of a primary key (id in a particular case) using boto3.
Table structure:
| id | name |
|-----|-------|
| 1 | Bob |
| 4 | Alice |
| 5 | Eve |
where id is a primary key (hash key) and there is no sort key (range key).
As a result, I should get 5 (the id largest value).
I have looked thought docs and this answer but didn't find an answer.
ScanIndexForward attribute from table.scan() method requires sort key. table.query() method requires condition (such as Key={"name":"Bob"}).
The id value is not autoincrementing (table may have missing id values) that is why this solution doesn't help.
Question: Is it possible to get largest id from a table without sort key? (Of course, I do not want to scan all table and find it using python.)
Thanks for reading!