PostgreSQL collects statistics on array membership for PostgreSQL arrays, but not for JSON arrays.
(PostgreSQL收集有关PostgreSQL阵列(而非JSON阵列)的数组成员资格的统计信息。)
This often leads to much better performance. (这通常会导致更好的性能。)
Plus PostgreSQL arrays are typed, which seems like a benefit for your case. (再加上PostgreSQL数组的类型,这似乎对您的情况有所帮助。)
Additional question: What if I want the integers to be unique?
(附加问题:如果我希望整数唯一,该怎么办?)
Can you expand on that?
(您能对此进行扩展吗?)
You want it to throw an error if you try to add a second copy of any one element? (如果您尝试添加任何一个元素的第二个副本,是否希望它引发错误?)
Silently ignore the addition? (默默无视加法?)
(Although neither case has in-place additions, it is really an assignment of the new array/JSONB which has happens to have one more element than the old one). ((尽管这两种情况都没有就地添加,但这实际上是新数组/ JSONB的一种分配,恰好比旧数组多了一个元素)。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…