我遇到了dynamodb的问题。我正在尝试验证其中包含的数据, 但扫描似乎只返回数据的一个子集,这里是我用python boto绑定的代码
#!/usr/bin/python
#Check the scanned length of a table against the Table Description
import boto.dynamodb
#Connect
TABLENAME = "MyTableName"
sdbconn = boto.dynamodb.connect_to_region(
"eu-west-1",
aws_access_key_id='-snipped-',
aws_secret_access_key='-snipped-')
#Initial Scan
results = sdbconn.layer1.scan(TABLENAME,count=True)
previouskey = results['LastEvaluatedKey']
#Create Counting Variable
count = results['Count']
#DynamoDB scan results are limited to 1MB but return a Key value to carry on for the next MB
#so loop untill it does not return a continuation point
while previouskey != False:
results = sdbconn.layer1.scan(TABLENAME,exclusive_start_key=previouskey,count=True)
print(count)
count = count + results['Count']
try:
#get next key
previouskey = results['LastEvaluatedKey']
except:
#no key returned so thats all folks!
print(previouskey)
print("Reached End")
previouskey = False
#these presumably should match, they dont on the MyTableName Table, not even close
print(sdbconn.describe_table(TABLENAME)['Table']['ItemCount'])
print(count)
print(sdbconn.describe_table)
给了我1748175和
print(count)
给了我583021。
我觉得这些应该永远匹配吗? (我知道6小时更新)但是在过去24小时内只添加了300行
有没有人知道这是不是dynamodb的问题?或者我的代码是否有错误的假设?
答案 0 :(得分:2)
最终弄明白,它与本地二级索引有关,它们在表格描述中显示为唯一项目,该表格有两个LSI,导致它显示实际存在的项目数量的3倍