AWScala icon indicating copy to clipboard operation
AWScala copied to clipboard

Limit value not respected in dynamodb query

Open nielsbergsma opened this issue 7 years ago • 1 comments

Hi,

I'm unable to limit the number of results in a dynamodb query operation, the following snippet returns 23k messages instead of 50. Why is the result set size so big?

private def getItems(sequenceFrom:Long) =
      table.query(
        keyConditions = Seq("partition" -> cond.eq(partitionKey), "sequence" -> cond.gt(sequenceFrom)),
        consistentRead = true,
        limit=50)
        .map(mapItemToRecord(partition, _))

nielsbergsma avatar Nov 03 '17 21:11 nielsbergsma

After reading the code, I believe the limit parameter only sets the "per-page-limit". But since the AWScala dynamodb table.query uses the QueryResultPager under the hood which gets converted into a stream it still will result in the full set of items.

You might need to use the ResultPager directly, to only get the first page.

torstenrudolf avatar Apr 23 '18 05:04 torstenrudolf