A DynamoDB `Query` with a filter returns only 12 items, but you know there are hundreds.
BeginnerTroubleshootingRDS, Aurora and DynamoDB
Answer
Likely causes → Each Query or Scan page reads at most 1 MB before the FilterExpression is applied. The response has a LastEvaluatedKey, and the code does not paginate.
Diagnose →
aws dynamodb query --table-name orders --key-condition-expression 'customerId=:c' \
--filter-expression '#s=:s' --expression-attribute-names '{"#s":"status"}' \
--expression-attribute-values '{":c":{"S":"c-9"},":s":{"S":"OPEN"}}' --no-paginate \
--query '[Count,ScannedCount,LastEvaluatedKey]'
Fix →
- Loop until
LastEvaluatedKeyis empty (the CLI paginates by default; SDKs have paginators) - If the filter discards most items, add a GSI keyed on that attribute so you query instead of filter
Prevent → Always use paginators, and compare ScannedCount with Count in reviews; a big gap means the key design is wrong.
More on RDS, Aurora and DynamoDB
The app cannot connect to RDS: `psql: error: connection to server at "mydb.abc.us-east-1.rds.amazonaws.com" (10.0.3.12), port 5432 failed: Connection timed out`.Beginner`FATAL: password authentication failed for user "postgres"` and nobody knows the master password.Beginner`FATAL: no pg_hba.conf entry for host "10.0.1.25", user "app", database "orders", no encryption`.IntermediateApp logs show `FATAL: remaining connection slots are reserved for non-replication superuser connections` (or MySQL `ERROR 1040 (HY000): Too many connections`).IntermediateRDS status shows `storage-full` and writes fail.IntermediateA read replica's `ReplicaLag` keeps growing and reports show stale data.Intermediate