3

This FQL attempting to fetch photos for my friends

[1]

{"query1":"SELECT owner, object_id, src_big FROM photo
WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=me())"}

provides this error response after thinking for a few seconds...

{"error_code":1,"error_msg":"An unknown error occurred"}

But this query to fetch albums for my friends will work and return a JSON object of album info

[2]

{"query1":"SELECT aid, owner, name FROM album
WHERE owner IN (SELECT uid2 FROM friend WHERE uid1=me())"}

Why does [2] work but not [1]?

jy jumper
  • 31
  • 3

2 Answers2

0

Indeed, that is strange. But this one does what you want:

SELECT owner, object_id, src_big 
FROM photo WHERE aid IN (
     SELECT aid FROM album WHERE owner in (
          SELECT uid2 FROM friend WHERE uid1=me()
     )
)

Have fun with pagination!

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
0

Query [1] returns all photo objects, whereas query [2] returns album objects. The number of photos will most of the times be much larger than the number of albums. So if each friend has 10 albums each with 100 photos, the query size increases and since FQL doesn't use any form of pagination you are pulling all at once.

Consider using multi-queries in the future or batch with LIMITS

phwd
  • 19,975
  • 5
  • 50
  • 78