9

In Facebook query language(FQL), you can specify an IN clause, like:

SELECT uid1, uid2 FROM friend WHERE uid1 IN (1000, 1001, 1002)

Does anyone know what's the maximum number of parameters you can pass into IN?

sakibmoon
  • 2,026
  • 3
  • 22
  • 32
Gaurav Sharma
  • 4,032
  • 14
  • 46
  • 72
  • I am seeing queries failing with an error like this: Exception: Received Facebook error response (code 601): Parser error: unexpected ',' at position 2083.) I don't have any extra ',' so I think there must be some limit of the size of SELECTs. I am not going via a browser but I do experience exactly the same problem via the browser. This points to a much smaller value than the 5000 below. – Mark Butler Mar 24 '14 at 17:15

4 Answers4

3

I think the maximum result set size is 5000

Ceilingfish
  • 5,397
  • 4
  • 44
  • 71
  • I'm going from the facebook developer boards http://forum.developers.facebook.com/viewtopic.php?pid=216570 – Ceilingfish May 05 '10 at 09:40
  • Downvoted. The question was not about how large can the *resultset* be, but *how many object_ids you can pass into `IN ()`* – rinogo Mar 24 '14 at 19:52
2

It may seem like an odd number (so perhaps I miss counted, but it's close ~1), but I can not seem to query more than 73 IN items. This is my query:

SELECT object_id, metric, value
FROM insights
WHERE object_id IN ( ~73 PAGE IDS HERE~ )
AND metric='page_fans'
AND end_time=end_time_date('2011-06-04')
AND period=period('lifetime')

This is using the JavaSCript FB.api() call.

sakibmoon
  • 2,026
  • 3
  • 22
  • 32
thaddeusmt
  • 15,410
  • 9
  • 67
  • 67
0

Not sure if there is an undocumented limit or it might be an issue of facebook fql server timeout.

You should check if there is a error 500 returned from FB web server which might indicate you are passing a too long GET statement (see Facebook query language - long query)

I realized my get was too long so instead of putting many numbers in the IN statement, i put a sub-query there that fetches those numbers from FB FQL - but unfortunately it looks like FB couldn't handle the query and returned an 'unknown error' in the JSON which really doesn't help us understand the problem.

Community
  • 1
  • 1
thedrs
  • 1,412
  • 12
  • 29
-2

There shoud not be a maximum number of parameters as there isnt in SQL IN as far as I know.
http://www.sql-tutorial.net/SQL-IN.asp

just dont use more parameters than you have values for the function to check because you will not get any results (dont know if it will give away an error as I never tried to).

TheChange
  • 209
  • 1
  • 3
  • 9
  • @Faruz: I dont really know, just guessed. Any Solution outrunning the limit maybe should be done in a better way – TheChange Mar 22 '10 at 14:46
  • In some SQL servers, the limit is the length of strings their SQL parser can handle, not the number of items in the "IN" clause. I'm not sure what the specific query-length limits are though. – Mark B Mar 31 '10 at 20:41
  • 1
    FQL and SQL have a little in common. FQL does not respect SQL standard at all. – Rok Kralj Sep 20 '12 at 19:50