130 likes | 514 Views
Amazon SimpleDB. Developer Brown Bag Jakub, Rande, Stefano, Tim, & Brett. Agenda. Recap/clarification on recent releases BatchPutAttributes Long running Select queries Select Count Step-by-step SimpleDB tutorial Your questions. BatchPutAttributes API.
E N D
Amazon SimpleDB Developer Brown Bag Jakub, Rande, Stefano, Tim, & Brett
Agenda • Recap/clarification on recent releases • BatchPutAttributes • Long running Select queries • Select Count • Step-by-step SimpleDB tutorial • Your questions
BatchPutAttributes API • Natural extension to PutAttributes • Up to 25 items per batch • Up to 256 attributes per item • Same as PutAttributes • One megabyte maximum request size • Improved throughput compared to PutAttributes • Fewer round trips with SimpleDB • Server side optimizations
BatchPutAttributes parameters • Rest:Item.X.ItemName=ItemNameItem.X.Attribute.Y.Name=AttributeNameItem.X.Attribute.Y.Value=AttributeValueItem.X.Attribute.Y.Replace=true/falseX: 0-24 itemsY: 0-255 attributes per item • Soap:<Item> <ItemName>...</ItemName> <Attribute> <Name>...</Name> <Value>...</Value> <Replace>...</Replace> </Attribute></Item> • Replace flag is optional and defaults to FALSE • Specify only when strictly necessary
More on BatchPutAttributes • BatchPutAttributes can be executed in parallel • Can achieve even higher throughput • Requests throttled aggressively (503) if excessive parallelism • Excessive depends on dataset • All or nothing semantics • API Call either accepted or rejected in its entirety • Call rejected when throttled (503) • Call rejected when limit exceeded
Long Running Selects • Query, QueryWithAttributes and Select all have a 5 seconds timeout • When timeout elapses • Query and QueryWithAttributes return 408 (timeout) error and no data • Select returns partial result set accumulated so far and NextToken to pick up where it left off • Individual partial result set could be empty • Client responsible for combining result sets • Select can complete even very complex queries over multiple iterations
Select Count(*) • Counts number of items that qualify predicate • Server side counting much more efficient • Count all items in domain: select count(*) from MyDomain • Count blue eyes in domain:select count(*) from MyDomain where EyeColor = 'blue' • Count up to 500 blue eyes in domain:select count(*) from MyDomain where EyeColor = 'blue' limit 500
Count(*) and timeouts • 5 second timeout enforced for Count(*) as well • Select will return NextToken together with partial count • Partial counts must be accumulated by client • Client issues “select count(*) from MyDomain” with no token • SimpleDB returns 20,000 and NextToken T1 • Client issues “select count(*) from MyDomain” with NextToken T1 • SimpleDB returns 50,000 and NextToken T2 • Client issues “select count(*) from MyDomain” with NextToken T2 • SimpleDB returns 35,000 and no NextToken • Final count is 20,000 + 50,000 + 35,000 = 105,000
Interchangeable NextToken • NextToken returned by Count(*) can be used for Select • WHERE and ORDER BY clauses must match • Can be used to efficiently bypass records in result set • Return 100 items after the first 100,000 forselect * from MyDomain where EyeColor = 'blue' and Age > '30’ order by Age • Client issues with no tokenselect Count(*) from MyDomain where EyeColor = 'blue' and Age > '30' order by Age limit 100000 • SimpleDB returns 65,000 and NextToken T1 • Client issues with NextToken T1 select Count(*) from MyDomain where EyeColor = 'blue' and Age > '30' order by Age limit 35000 • SimpleDB returns 35,000 and NextToken T2 • Client issues with NextToken T2select * from MyDomain where EyeColor = 'blue' and Age > '30' order by Age limit 100
SimpleDB Tutorial AWS Evangelist Mike Culver