If you’re a developer you’ll know that one of the most important things to making efficient code is to reduce your code’s dependency on SQL queries. Rather than running 1,000 SQL “INSERT” queries for 1,000 individual items for example, it’s better to batch those items into a single “INSERT” statement. There are other methods that can be used to improve query performance as well including general query batching in which multiple queries are batched into a single request.
Last night Facebook announced a pretty cool upgrade which is FQL.multiquery. The service enables developers to batch multiple queries into a single request. Additionally, the new service allows for subqueries by reference. As Julie Tung writes on the Facebook developer blog, queries can batched into an associative array. For example:
$queries = {
"user_stream":"SELECT post_id, actor_id, message FROM stream
WHERE source_id=UID",
"actor_info":"SELECT uid, name, pic_square FROM user
WHERE uid IN (SELECT actor_id FROM #user_stream)"
}
$facebook->api_client->fql_multiquery($queries);
Whether you are looking to reduce the number of FQL calls that you are making, or just looking to create cleaner code, FQL.multiquery is an efficient service for developers. I haven’t had the opportunity to test out the FQL.multiquery service but I’ll most definitely take advantage of this on future apps.
And yes, if you’re wondering that’s an image of the Matrix. That’s what programming in real life looks like.






![[Inside Social Apps 2012]](http://www.allfacebook.com/wordpress/wp-content/themes/allfacebook2/images/ISA2012_336x100_F_RegisterNow.gif)
![[AllFacebook Stats: Facebook Analytics for Your Business]](http://www.allfacebook.com/wordpress/wp-content/themes/allfacebook2/images/stpro_allfacebookstats.gif)
![[How can Facebook change your business?]](http://www.allfacebook.com/wordpress/wp-content/themes/allfacebook2/images/FMB_A_MAY2011_336x100_F.gif)


Looks more like Oracle. I wouldn't f&ck with Oracle's intellectual property.
Comment by hwekfjewf — June 17, 2009 @ 1:25 pm
"And yes, if you’re wondering that’s an image of the Matrix. That’s what programming in real life looks like."
Hahaha, made me laugh. Thanks guys
In all seriousness, this is an excellent addition, props to the FB team.
Comment by Sebastian — June 17, 2009 @ 1:34 pm
There are alot of fql examples for facebook on coderun website.
CodeRun is a new online IDE with online examples.
CodeRun supports variuos languages.
Comment by Roman — June 21, 2009 @ 6:34 am