扫描DynamoDB表未返回数据 [英] Scan DynamoDB table is not returning data

查看:116
本文介绍了扫描DynamoDB表未返回数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从dynamodb数据库表中扫描失败的令牌计数,而没有任何索引。它从数据库返回0。我怀疑它没有扫描完整的数据库。下面是我的方法和 dynamoDBClient 工作条件之一,它具有连接详细信息。我只在此处发布扫描查询部分

I am trying to scan failed token counts from dynamodb database table without any indexes. It is returning 0 from the database. I doubt it is not scanning complete database. Below is my method and the dynamoDBClient working condition one and it has connection details. I am posting here only the scan query part

public int getFailedAuthStatusCount() {

    Map<String,String> expressionAttributesNames = new HashMap<>();
      expressionAttributesNames.put("#status","auth_status");

    Map<String, AttributeValue> expressionAttributeValues = new HashMap<String, AttributeValue>();
    expressionAttributeValues.put(":val", new AttributeValue().withS("FAIL"));

    ScanRequest scanRequest = new ScanRequest()
              .withTableName("Token")
              .withFilterExpression("#status = :val")
              .withExpressionAttributeNames(expressionAttributesNames)
              .withExpressionAttributeValues(expressionAttributeValues);
    ScanResult scanResult = dynamoDBClient.scan(scanRequest); //client is working fine.
    return scanResult.getCount();
  }

这是响应。

{Items: [],Count: 0,ScannedCount: 1456,LastEvaluatedKey: {GUID={S: 0c4b281e6f9290c0fb3bf13f28c88fd,}, VENDOR={S: DELL,}},}

我的请求出了什么问题?

what is wrong with my request?

推荐答案

您的请求没有问题。扫描时,您必须继续使用先前的 LastEvaluatedKey 作为下一个请求的 ExclusiveStartKey 重新提交请求,直到不再收到响应中的 LastEvaluatedKey

Nothing is wrong with your request. When scanning, you have to continue resubmitting the request with the prior LastEvaluatedKey as the next request's ExclusiveStartKey until you no longer receive a LastEvaluatedKey in the response.

您的第一个请求仅评估第一个 ScannedCount:表格中有1456 个项目(≈1MB数据)。

Your first request is only evaluating the first ScannedCount: 1456 items in the table (≈ 1MB of data).

请参见 https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.Pagination

在所有数据库环境中,表扫描都是缓慢且昂贵的。这就是索引很重要的关键原因。 DynamoDB由于可用的底层API而使这一点更加明显。

Table scans are slow and expensive in all database environments. That's a key reason why indexes are important. DynamoDB makes this more apparent because of the low-level API that's available.

这篇关于扫描DynamoDB表未返回数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆