Query & Scan

Query DynamoDB tables by partition key or scan with filter expressions.

Overview

DynamoDB provides two ways to read multiple items: Query and Scan. Stackpane supports both operations with a visual interface for building key conditions and filter expressions.

Query vs Scan

Understanding the difference between Query and Scan is important for both performance and cost:

  • Query reads items that share a specific partition key value. It is efficient because DynamoDB uses the partition key to locate the data directly. You can optionally add sort key conditions to narrow results further.
  • Scan reads every item in the table and optionally applies a filter expression to discard items that do not match. It always examines the entire table (or the entire page), which consumes more read capacity and takes longer on large tables.

Use Query whenever you know the partition key value. Use Scan when you need to browse all items or search across partition keys.

Querying by Partition Key

  1. Select a table and open the query panel from the toolbar.
  2. Select Query as the operation mode.
  3. Enter the partition key value. Stackpane auto-detects the key schema, so the partition key field name and type are pre-filled.
  4. Click Run to execute the query.

Results appear in the item table, replacing the current view.

Sort Key Conditions

If the table has a sort key, you can add a condition to narrow results:

  1. Enable the sort key condition toggle.
  2. Select an operator: =, <, <=, >, >=, begins_with, or between.
  3. Enter the sort key value (or two values for between).
  4. Click Run.

Sort key conditions are evaluated server-side by DynamoDB, so they reduce the amount of data returned and read capacity consumed.

Scanning with Filters

  1. Select a table and open the query panel from the toolbar.
  2. Select Scan as the operation mode.
  3. Optionally add one or more filter expressions (see below).
  4. Click Run to execute the scan.

Without filter expressions, a scan returns all items in the table, paginated according to your page size setting.

Adding Filter Expressions

Filter expressions let you narrow scan results by attribute values:

  1. Click Add Filter to create a filter clause.
  2. Enter the attribute name to filter on.
  3. Select an operator from the dropdown.
  4. Enter the comparison value.

You can add multiple filter clauses. All clauses are combined with AND logic — items must match every clause to be included in the results.

Supported Filter Operators

OperatorDescriptionExample
equalsAttribute equals the valuestatus = "active"
notEqualsAttribute does not equal the valuestatus != "deleted"
greaterThanAttribute is greater than the valueage > 18
lessThanAttribute is less than the valueprice < 100
greaterOrEqualAttribute is greater than or equal to the valuescore >= 90
lessOrEqualAttribute is less than or equal to the valuecount <= 10
inAttribute matches one of the provided valuescategory in ["books", "music"]

Important: Filters and Read Capacity

Filter expressions are applied after DynamoDB reads the data from disk. A filtered scan still reads the entire table — the filter only removes non-matching items from the response. This means a filtered scan consumes the same read capacity as an unfiltered scan. For cost-efficient filtering, use Query with sort key conditions instead of Scan with filters when possible.

Pagination

Both Query and Scan results are paginated:

  • Results load in pages based on your configured page size.
  • Click Load More at the bottom to fetch the next page.
  • Stackpane automatically passes the LastEvaluatedKey from the previous response to continue from where the last page ended.
  • When there are no more pages, the Load More button disappears.

Result Limits

Set a maximum number of items to return from a query or scan:

  1. Enter a value in the Limit field in the query panel.
  2. DynamoDB stops reading after returning that many items (before applying filters for scans, after key conditions for queries).

Use limits to sample data from large tables without scanning the entire dataset.

Performance Considerations

  • Prefer Query over Scan: Query targets a specific partition and is significantly faster and cheaper on large tables.
  • Use sort key conditions: Sort key conditions reduce the data read server-side, improving both speed and cost.
  • Be cautious with full table scans: Scanning a table with millions of items consumes substantial read capacity and may take a long time. Use pagination and limits to control the scope.
  • Filters do not reduce read costs: Filter expressions reduce the data returned to Stackpane but do not reduce the data DynamoDB reads internally. Design your key schema to support your most common access patterns.

Tips

  • The query panel remembers your last operation mode and filter settings for the current session
  • Use the partition key value from an item’s inspector to quickly query for related items in the same partition
  • Combine sort key conditions with filter expressions for precise results within a partition