Amazon SimpleDB just released an update that includes a new feature called QueryWithAttributes. With this update, developers will be now able to retrieve all the information associated with items returned as a response to a particular query. The feature provides additional flexibility because it enables you to retrieve anywhere between one and all attributes for each item. This highly requested feature simplifies application development process for all clients of Amazon SimpleDB. Instead of issuing a Query request followed by a series of GetAttributes requests, application designers can now use a single API call to retrieve all information about items stored in Amazon SimpleDB.
I am very excited about this new feature because it simplifies my application code. This is useful for developers who are not used to parallel programming or who utilize programming languages that do not support parallel programming.
The updated API documentation is here. I also highly recommend reading the Query 101, Query 102, and the best practices articles from our resource center. Amazon SimpleDB is still in limited beta. However if you sign up for the service at aws.amazon.com/SimpleDB you’ll be the first to know when additional applications are accepted.
If you don’t list specific attributes in your query, then all attributes are returned—which is the default behavior of this new API method.
There’s a FAQ below; however I believe that examples always help developers understand what the changes mean in terms of writing code:
Current Query Syntax:
Domain = ZipCode
[‘State’ = ‘WI’]
Calling the Query method returns
New QueryWithAttributes Syntax
The new query is identical in every way except that the API has a new method. Called—of course—QueryWithAttributes:
Domain = ZipCode
[‘State’ = ‘WI’]
Calling the QueryWithAttributes method returns
<Attribute><Name>city</Name><Value>FOND DU LAC</Value></Attribute>
<Attribute><Name>county</Name><Value>FOND DU LAC</Value></Attribute>
Q: Can I use the same query language?
Yes, the query language is exactly the same as for the regular Query API call.
Q: Will I get back the same set of items?
Yes, the overall set of items that will match a given query expression is exactly the same as that for the regular Query API call.
Q: How many attributes can I retrieve for each item?
You can retrieve anywhere between one and all attributes for each item. The default behavior is to return all attributes, but you can specify a list of specific attributes to return.
Q: Will my result set be paginated?
Yes, Amazon SimpleDB paginates the result set if it exceeds specified maximum number of items or a total overall response size of 1 MB.
Q: How many items can I retrieve in one page of results?
You can indicate the maximum number of items to return per page that can be between 1 and 250 (default 100). Amazon SimpleDB will attempt to return as many items as possible per page without exceeding the maximum byte size limit (1 MB) and the maximum number of items specified.
Q: What happens to page size if my attributes are very large?
Your page size will likely be smaller than the maximum number of items specified, since the overall size of the response object will approach the limit of 1 MB.
Q: Will I ever get one item split across multiple pages of results?
No, an item will never get split across multiple pages of results. All specified attributes for a given item will be returned within the same page of results.
Q: Does the query timeout apply to my queries?
Yes, the same query timeout applies to long running queries.
Q: How much does each call cost?
The cost of each call is proportional to the amount of system resources that it consumes. You can monitor the cost through the BoxUsage parameter, which is returned with every response.
Q. Is the Amazon SimpleDB Beta open to all comers now?
Amazon SimpleDB is still in limited beta. However if you sign up for the service at http://aws.amazon.com/SimpleDB you’ll be the first to know when additional applications are accepted.