Facebook - max number of parameters in “IN” clause

2019-04-22 10:48发布

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?

4条回答
倾城 Initia
2楼-- · 2019-04-22 11:14

I think the maximum result set size is 5000

查看更多
ら.Afraid
3楼-- · 2019-04-22 11:21

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.

查看更多
做自己的国王
4楼-- · 2019-04-22 11:23

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).

查看更多
来,给爷笑一个
5楼-- · 2019-04-22 11:29

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.

查看更多
登录 后发表回答