Reading Data From a Table
With SQL, you use the
SELECT statement to retrieve one or more rows from
a table. You use the WHERE clause to determine the data that is returned to
DynamoDB provides the following operations for reading data:
GetItem– Retrieves a single item from a table. This is the most efficient way to read a single item, because it provides direct access to the physical location of the item. (DynamoDB also provides
BatchGetItemoperation, allowing you to perform up to 100
GetItemcalls in a single operation.)
Query– Retrieves all of the items that have a specific partition key. Within those items, you can apply a condition to the sort key and retrieve only a subset of the data.
Queryprovides quick, efficient access to the partitions where the data is stored. (For more information, see Partitions and Data Distribution.)
Scan– Retrieves all of the items in the specified table. (This operation should not be used with large tables, because it can consume large amounts of system resources.)
With a relational database, you can use the
SELECT statement to join data from
multiple tables and return the results. Joins are fundamental to the relational
model. To ensure that joins execute efficiently, the database and its applications
should be performance-tuned on an ongoing basis.
DynamoDB is a non-relational NoSQL database, and does not support table joins. Instead, applications read data from one table at a time.
The following sections describe different use cases for reading data, and how to perform these tasks with a relational database and with DynamoDB.