简体   繁体   English

如何使用查询从DynamoDb中的表获取所有记录

[英]How to get all records from a table in DynamoDb using query

Newbie to DynamoDb 新手到DynamoDb

I have a table in AWS DynamoDb as below 我在AWS DynamoDb中有一个表格如下

tblCustomer tblCustomer

Id Name Email
1  Abc  abc@gmail.com
2  Xyz  xyz@gmail.com

It's a huge table. 这是一张大桌子。 While exploring on around it. 在探索它的同时。 Query is better than Scan . QueryScan更好。 So I chose Query over Scan. 因此,我选择了“通过扫描查询”。

This is how my C# function looks like. 这就是我的C#函数的样子。

AmazonDynamoDBClient client = new AmazonDynamoDBClient();

var request = new QueryRequest
{
 TableName = "tblCustomer",
 ProjectionExpression = "Name, Email"
 };

 var response = await client.QueryAsync(request);

 foreach (Dictionary<string, AttributeValue> item in response.Items)
 {

 }

But this is throwing the exception 但这引发了异常

KeyConditionExpress cannot be null

Here I don't need to have KeyConditionExpress as I need to get all the customers. 在这里,我不需要KeyConditionExpress,因为我需要吸引所有客户。

How can I get all the records from tblCustomer in most efficient way? 如何以最有效的方式从tblCustomer获取所有记录?

Thanks! 谢谢!

A query is better than a scan if you are looking to return a subset of the records - what you are trying to do (a query with no conditions) is the functional equivalent of a scan anyway, so you might as well use the scan. 如果您希望返回记录的子集,则查询比扫描要好-无论如何,您要尝试执行的操作(无条件查询)在功能上等同于扫描,因此您最好使用该扫描。

That said, if you find yourself needing to run full-table scans often, it might indicate a problem with your design - scans are expensive and slow and should be used only when necessary. 就是说,如果您发现自己需要经常运行全表扫描,则可能表明您的设计存在问题-扫描既昂贵又缓慢,应仅在必要时使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将查询中的所有结果获取到 aws dynamodb 表? - How to get all results in a query to a aws dynamodb table? DynamoDB 查询 | 如何获取按最新时间戳排序的所有记录? - DynamoDB Query | How can I get all records sorted by newest timestamp? 无法使用查询 DynamoDB 获取所有项目 - unable to get all items using query DynamoDB 有没有办法使用来自 DynamoDB 的 CrudRepository 按给定值获取列表中的所有记录? - Is there any way to get all records by given value in a list using CrudRepository from DynamoDB? 如何使用 dynamodb 通过属性从表中获取项目 - How to get item from table by attirbute using dynamodb 如何基于列表类型属性从DynamoDB表获取记录,而不进行扫描操作 - How to get records from DynamoDB table based on list type attribute, without scan operation 如何更新DynamoDB中的所有记录? - How to update all records in DynamoDB? 使用 Java 高级 API 从 DynamoDB 表中获取所有表项 - Get all the table items from DynamoDB table using Java High Level API 如何从 dynamodb 中批量删除所有没有 TTL 的记录? - How bulk delete all records without TTL from dynamodb? Java:使用Mapper在DynamoDB表中查询范围键的所有值 - Java: Query DynamoDB table for all values for a Range key using Mapper
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM