Chapter 8. Facebook Query Language (FQL)

Let’s say that you’d been puttering around town in a beat-up old jalopy and you pulled up to a traffic light. You dig your jalopy in a very Archie kind of way, even though it’s a little slow sometimes and uses a lot of gas, but it’s your car and it’s all you’ve known. And now let’s say, while you’re sitting there at the light, a brand new Formula 1 race car comes screaming up to a stop right next to you, tires smoking. Sure, your jalopy is nice and all, but think how much faster you could get your shopping done in that baby! Now think of your jalopy as the Facebook API and the sleek, sexy, speedy race car as FQL.

See, here’s the dirty little secret about APIs: they’re all the rage with the kids these days, and they’re a joy to program in, but they’re not particularly efficient when you’re worried about your app scaling to hundreds of thousands of users. If you’re building a Facebook app that you think will really take off and you want to make sure you’re being as future-proof as possible, you should consider using FQL for key queries for the following reasons:

Decreased result sets

When you’re working with the API and you request the friends of a specific user, you get all the info back about everybody and then parse through the results. FQL gives you the ability to limit the fields you want returned and to put more conditions on your queries, thereby reducing the size of the result set and the bandwidth consumed. If you change a key query from ...

Get Facebook Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.