0

This is a follow up to: How to filter male and female id in Facebook graph api

Suppose the task at hand is to find 10 female friends of the user. You can perform this with either the FQL or the Graph API (see original question).

Intuitively, I would expect FQL to be much faster because Facebook is taking care of the calculations for you. However, is this necessarily true?

1 Answer 1

5

I just ran a quick test (n>=3) using the Graph API Explorer, alternating between the API call and the FQL below.

This API call:

/me/friends?fields=name,gender 

returned data from 300ms to 6223ms, avg = 1780ms.

This FQL call:

SELECT name, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex = "male" LIMIT 10 

returned data in 457ms to 8075ms, avg. 3690ms.

So the API call is about 20-30% faster than the FQL call, although the data doesn't match up, so it's really a crap shoot whether the API call will execute faster than the FQL call at any given time.

With the API call you still have to deal with filtering the results on your end to find 10 friends of the gender you're looking for. With FQL you can immediately loop through the result set and display them.

For what it's worth, if you compare an FQL call with everything from the AND on removed, so you're getting similar data to the API, that beats the API easily. Data is returned in 320 to 571 ms, avg. = 390ms.

Sign up to request clarification or add additional context in comments.

4 Comments

FQL gives you more flexibility and makes a big difference when you try batch requests. Otherwise, the response times would be more or less the same.
Since the API doesn’t allow you to filter these results – and therefor you could have to get quite a lot of users to find ten that are of female gender – whereas FQL allows you to filter by gender and limit the result to 10, I think FQL would be my way to go with concerning such a requirement.
I don't think your comparison is fair. You need to include the time it takes to filter by gender and limit to 10 users.
True, but script execution time is negligible compared to the API call time. The more significant time is the time it takes to WRITE the code to ensure you have enough results and filter them.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.