AWS SimpleDB的默认结果限制为100,我试图从我的数据库中获取最后20条记录。他们的在线帮助说明:“只要where和order by子句匹配,count(*)和select返回的下一个标记是可以互换的。例如,如果要在第一个10,000之后返回200个项目(类似于偏移量) ),您可以使用限制条款10,000执行计数,并使用下一个标记返回接下来的200项选项。“
所以我正在尝试研究如何执行这两个操作。我首先得到记录数量的计数(在我的例子中约为160),然后我从中减去20以创建偏移量。但AWS仍在返回前100条记录。我假设“// ++”之间的代码在创建偏移时不正确。
//++ AWS has display limit of 100 so create offset by starting from count - 20
NSString *sdbAppOffset = [NSString stringWithFormat:@"select count(*) from %@ limit %i",sdbAppUse,iDbaseRecordCountOffset];
SimpleDBSelectRequest *selectOffsetRequest = [[SimpleDBSelectRequest alloc] initWithSelectExpression:sdbAppOffset];
selectOffsetRequest.consistentRead = YES;
SimpleDBSelectResponse *selectOffSetResponse = [sdbClient select:selectOffsetRequest];
//NSLog(@"sdbAppUse count %i",[selectOffSetResponse.items count]);
//++
NSString *sdbAppUseString = [NSString stringWithFormat:@"select * from %@",sdbAppUse];
SimpleDBSelectRequest *selectRequest = [[SimpleDBSelectRequest alloc] initWithSelectExpression:sdbAppUseString];
selectRequest.consistentRead = YES;
SimpleDBSelectResponse *selectResponse = [sdbClient select:selectRequest];
NSLog(@"sdbAppUse count %i",[selectResponse.items count]);
for (int x = 0; x < [selectResponse.items count]; x++) {
SimpleDBItem *registerUser = [selectResponse.items objectAtIndex:x];
for (SimpleDBAttribute *attribute in registerUser.attributes) {
NSLog(@"trackUsage registerUser |%@|, name |%@|, value |%@|",registerUser.name, attribute.name, attribute.value);
}
}