SQL查询的最大长度 [英] Maximum length of an SQL Query
本文介绍了SQL查询的最大长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SELECT f.*
FROM feeds f,
user_feeds uf
WHERE (f.id=uf.feed_id and uf.user_id in (1,2,5,6,23,45))
ORDER BY created_at DESC
这是用于构造用户供稿的查询。我对此查询的问题是,(uf.user_id in())随着他关注的用户数量的增加而增加。
This is a query used to construct a user's feeds. The issue I have with this query is that the "uf.user_id in ()" increases as the number of users he follows increase.
允许的最大长度是多少一个SQL查询?
是否有更好的方法来实现上述查询?
What is the allowed max length of an SQL query ? Is there a better way to implement my above query ?
注意:我正在使用ActiveRecord。我正在使用Postgres。
Note: I am using ActiveRecord. And I am using Postgres.
推荐答案
PostgreSQL可以处理的查询的最大长度为2147483648个字符(带符号的4个字节的整数) ;请参见 src / include / lib / stringinfo.h
)。
The maximum length of a query that PostgreSQL can process is 2147483648 characters (signed 4-byte integer; see src/include/lib/stringinfo.h
).
这篇关于SQL查询的最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文