I have been developing an iPhone app which queries a server that relays data I store in Amazon SimpleDB. I have a database table of “Submissions” by various users. I am interfacing with Facebook to retrieve Facebook Friends and wish to make a query to “Submissions” to find posts by friends – like:
SELECT * FROM submissions WHERE userID = '00123' OR userID = '00124' OR ....
(through complete list of friends)
I think this will run into an Amazon query limit with this kind of select statement –
[Maximum number of comparisons per Select expression: 20]
Can you think of a way to elegantly pull this off with SimpleDB?
I’d rather not have to do a bunch of 20 person queries.
Or, do I need to move to a different database package and then do cross-table queries?
Thanks!
You’re needing either an IN clause or a join to a temp table. Unfortunately AmazonSimpleDB has its limitations. We abandoned it on a promising project for this very reason. We went down the path of multithreading and using the NextToken functionality before we switched gears.
You could execute parallel (multithreaded) queries to SimpleDB to get submissions, each query looking for up to 20 user IDs and then merging the results into one list. Still, it’s probably time to consider a switch to MySQL or SQL Server to be able to upload a list of IDs as a temp table and then do a simple join to get the results.