PostgreSQL 中 OFFSET 和 LIMIT 可以接受的最大数量是多少

问题描述 投票:0回答:1

OFFSET 和 LIMIT 能否接受 BIGINT 大小的整数或仅接受 INTEGER? (最多 2147483647 或 9223372036854775807)

我在 postgresql 文档中找不到任何提及

我想到了这一点,因为用户可以通过请求发送偏移量和限制参数,但我很困惑,我应该接受 int64 还是 int32

sql postgresql go
1个回答
0
投票

很容易发现:
db<>fiddle 的演示

create table t(c)as values (1),(2);
select*from t limit 1 offset 1;
select*from t limit 32767 offset 0;--upper bigint limit
select*from t limit 2147483647 offset 0;--upper integer limit
select*from t limit 9223372036854775807 offset 0;--upper bigint limit
c
2
c
1
2
c
1
2
c
1
2

超越

bigint
就是它开始抱怨的地方:

select*from t limit 9223372036854775808 offset 0;--right above upper bigint limit
ERROR:  bigint out of range
select*from t limit 1e131071 offset 0;--upper numeric limit
ERROR:  bigint out of range
© www.soinside.com 2019 - 2024. All rights reserved.