Open dead10ck opened 1 month ago
Hey @dead10ck, thanks for reaching out. AWS CLI obscures service pagination parameters like --limit
in favor of the CLI pagination parameters (--max-items
being the analog to --limit
). This is done so that pagination in the CLI is consistent between services. However, the service pagination parameters still work, as you mentioned. Please let me know if you have any follow-up questions.
But pagination doesn't serve the same purpose as limiting the results of a scan or query. When you --limit
a query to 1, you are only charged RCUs for that one row; when you use --max-items
, you are charged RCUs for I think the full result set? You can verify by checking the consumed RCUs.
You should be able to accomplish the same thing using a combination of --max-items
and --page-size
.
aws dynamodb scan --table-name testTable --limit 1
...
"Count": 1,
"ScannedCount": 1,
...
If using only --max-items
, all items are scanned as you mentioned. aws dynamodb scan --table-name testTable --max-items 1
...
"Count": 3,
"ScannedCount": 3,
"ConsumedCapacity": null,
"NextToken": "eyJFeGNsdXNpdmVTdGFydEtleSI6IG51bGwsICJib3RvX3RydW5jYXRlX2Ftb3VudCI6IDF9"
Using both --max-items
and page-size
correctly restricts the number of scanned and returned items. aws dynamodb scan --table-name testTable --page-size 1 --max-items 1
...
"Count": 1,
"ScannedCount": 1,
"ConsumedCapacity": null,
"NextToken": "eyJFeGNsdXNpdmVTdGFydEtleSI6IHsiTmFtZSI6IHsiUyI6ICJDYW1teSJ9fX0="
Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.
Ah, you are right, thanks! Is that documented anywhere? That doesn't seem like an obvious way to use query limits with the CLI.
It's explained a bit in the description for page-size
.
The size of each page to get in the AWS service call. This does not affect the number of items returned in the command’s output. Setting a smaller page size results in more calls to the AWS service, retrieving fewer items in each call.
--page-size 1
means that it will scan one item at a time until it reaches --max-items
total items (in this case also one).
Describe the bug
The
dynamodb query
anddynamodb scan
subcommands both seem to respond to a--limit
parameter by setting theLimit
query parameter as expected; however,--limit
is not documented at all in the help pages.Expected Behavior
--limit
should be documentedCurrent Behavior
It is not
Reproduction Steps
Run
aws dynamodb query help
Possible Solution
No response
Additional Information/Context
No response
CLI version used
aws-cli/2.17.26 Python/3.11.9 Linux/6.5.0-45-generic exe/x86_64.ubuntu.22
Environment details (OS name and version, etc.)
Ubuntu 22.04