在Postgres的integer[]
列中搜索某个值还有其他方法吗?
我当前安装的Postgres版本 * 不 * 允许以下语句:
SELECT * FROM table WHERE values *= 10;
数组示例:
'{11043,10859,10860,10710,10860,10877,10895,11251}'
'{11311,10698,10697,10710,10712,10711,10708}'
语句应返回数组包含'10710'
的每一行。
在Postgres的integer[]
列中搜索某个值还有其他方法吗?
我当前安装的Postgres版本 * 不 * 允许以下语句:
SELECT * FROM table WHERE values *= 10;
数组示例:
'{11043,10859,10860,10710,10860,10877,10895,11251}'
'{11311,10698,10697,10710,10712,10711,10708}'
语句应返回数组包含'10710'
的每一行。
3条答案
按热度按时间ahy6op9u1#
对于相等性检查,您只需:
阅读手册中的ANY/SOME。
对于大表/大数组,考虑使用索引支持的数组运算符,例如:
参见:
对于整数数组,考虑附加模块
intarray
:相关:
cbjzeqam2#
快速搜索将是如此,但你应该使用索引gist或gin为intarray类型Postgres intarray
inb24sb23#