Database Reference
In-Depth Information
BatchGetItem
If we need to read data from multiple tables at the same time, then the
BatchGetItem
operation is advised. It is advised to use this operation whenever and wherever possible be-
cause it consumes the read throughput equally across all the tables in question. The follow-
ing code tries to fetch three items from
Tbl_Library
and one item from
Tbl_Book
:
{
"RequestItems": {
"Tbl_Library": {
"Keys": [
{"Name":{"S":"Library of Congress"}},
{"Name":{"S":"National Diet Library"}},
{"Name":{"S":"Royal Danish Library"}}],
"AttributesToGet": ["Country","City"]},
"Tbl_Book": {
"Keys": [
{"BookTitle": { "S": "SCJP" }, "Author ": { "S":
"Kathy" } }],
"AttributesToGet":
["BookTitle","Language","Edition"]}},
"ReturnConsumedCapacity": "TOTAL"
}
The response of the
BatchGetItem
operation is as follows:
{
"Responses": {
"Tbl_Library": [
{
"Name":{"S":"Library of Congress"},
"Country":{"S":"United
States"},"City":{"S":"WashingtonDC"} },
{
"Name":{"S":"National Diet Library"},
"Country":{"S":"Japan"},"City":{"S":"Tokyo"} },
{
"Name":{"S":"Royal Danish Library"},