Now, scan the new global secondary index GSI_2
on the employees
table. In using our new sparse index we expect that we’ll consume read capacity for fewer items. We’ll use the sparse index as a very effective filter to improve efficiency for this access pattern.
response = table.scan(
Limit=pageSize,
IndexName='GSI_2'
)
Run the following AWS CLI command to execute this scan using the sparse index.
python scan_for_managers_gsi.py employees 100
Parameters:
employees
100
(this is size of the pagination for the scan).The following output includes the scanned count and the execution time.
Number of managers: 84. # of records scanned: 84. Execution time: 0.287754058838 seconds
Observe the scanned count and execution time using the sparse index. How does this compare to the result achieved from the Scan of the base table in Step 2? The sparse index has less data and is more efficient.