When I scan () in Dynamodb without a filter and retrieve only 10 objects, does it still access the entire database?

For example (using Boto):

import boto

db = boto.connect_dynamodb()

table = db.get_table('MyTable')
res = table.scan(attributes_to_get=['id'], max_results=10)

for i in res:
    print i

If I have 1000 objects in my table, will it check them all or stop after 10? If it really read all 1000 objects, how can I read it only the first 10?

+5
source share
2 answers

In accordance with the documentation for calculating the unit of capacity , only up to 1 MB of data will be processed for one request.

, , , Amazon DynamoDB. Amazon DynamoDB 1 , .

"" 1000 . , "limit" ( 100) , limit .

, , . , 1 .

Amazon ,

consumed_capacity = math.ceil(sum(parsed_data_size)/1KB)

, , :

import boto
db = boto.connect_dynamodb()

# Notice the "layer1" operation
res = db.layer1.scan('MyTable', attributes_to_get=['id'], limit=10)

print res['ScannedCount']
+3

, : .

, ( "id" ) - , 10 , .

10 , :

  • 1 , ExclusiveStartKey = result ['LastEvaluatedKey'].

  1. , " " "".
0

All Articles