[英]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
. Query
比Scan
更好。 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.