I am trying to grab the latest links shared by a user’s facebook friends in the last few days. Let’s say in the last 7 days:
Using FQL, I am able to grab this for up to 20 friends at a time:
$fql = "SELECT link_id, owner, created_time, title, summary, url, image_urls FROM link WHERE owner IN (select uid2 from friend where uid1 = me() LIMIT 20) AND created_time >= $_7ago";
If I set the friend count limit from 20 to something higher, the query crashes. My current solution is to repeat this query, breaking down (say) 1000 friends into groups of 20s inside a loop. This actually worked but it takes more than five minutes to run.
I’ve also tried multi-querying this way (and the speed hasn’t increased):
"links":"select uid2 from friend where uid1 = me() LIMIT 20",
"stats":"SELECT owner, owner_comment, title, summary, url, image_urls FROM link WHERE owner IN (select uid2 from #links) AND created_time >= \"' . $_7ago . '\""
Is there a faster alternative / solution?
http://www.pixable.com/ <- manages to pull monthly photos shared by friends in less than 3 seconds
Multiqueries can be used to fire multiple non-related queries too. First get the friend uids, then create the individual queries by sharding the uids into chunks and fire off all the queries at once. In js sdk this would look like:
The documentations states that this should be faster than using the batch api interface:
In firebug the first

console.log(results)should show something similar to this (actual id’s are removed/truncated for space constrains):