Reputation: 7555
Newbie to DynamoDb
I have a table in AWS DynamoDb as below
tblCustomer
Id Name Email
1 Abc [email protected]
2 Xyz [email protected]
It's a huge table. While exploring on around it. Query
is better than Scan
.
So I chose Query over Scan.
This is how my C# function looks like.
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.
How can I get all the records from tblCustomer in most efficient way?
Thanks!
Upvotes: 2
Views: 5887
Reputation: 46839
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.
Upvotes: 4