PostgreSQL中数组类型的大小/长度限制

时间:2022-06-01 16:30:37

I'm working a web project with PostgreSQL as a databases. I'm trying to build a structure of the web's databases that include a vector space model table. I created a table with attribute terms and docId[] where docId is the document ID of the term. type of the docId is integer[]. So I can input a term with the document list that include the term in one single array. But the docId's array of term maybe will containing a lot of entries.

我正在使用PostgreSQL作为数据库进行Web项目。我正在尝试构建包含向量空间模型表的Web数据库结构。我创建了一个包含属性术语和docId []的表,其中docId是术语的文档ID。 docId的类型是整数[]。因此,我可以在文档列表中输入一个术语,该术语列表包含单个数组中的术语。但docId的术语数组可能会包含很多条目。

so my question is: how many max size of array one dimmension in postgres?

所以我的问题是:在postgres中有多少个最大尺寸的阵列一个dimmension?

thanks :)

谢谢 :)

2 个解决方案

#1


9  

There is no size limit on Postgres arrays. There must be limits on row or column size, but that would run in the millions of entries.

Postgres数组没有大小限制。行或列大小必须有限制,但这将在数百万条目中运行。

A more SQL way to relate term to document is a 1 to many relation. This is implemented like:

将术语与文档相关联的更多SQL方法是1对多关系。这实现如下:

table term: columns term_id, term, document_id
table document: columns document_id, summary, ...

The document_id column in the term table is called a foreign key.

术语表中的document_id列称为外键。

#2


5  

I didn't find any limitation in number of elements in array, but there is in field size. Maximum size of field in PostgreSQL is 1GB, so it is approximately 268435456 elements in array. Be aware that indexing such array or searching through it would probably be useless.

我没有发现数组中元素数量有任何限制,但有字段大小。 PostgreSQL中字段的最大大小为1GB,因此它在数组中大约为268435456个元素。请注意,索引此类数组或搜索它可能是无用的。

#1


9  

There is no size limit on Postgres arrays. There must be limits on row or column size, but that would run in the millions of entries.

Postgres数组没有大小限制。行或列大小必须有限制,但这将在数百万条目中运行。

A more SQL way to relate term to document is a 1 to many relation. This is implemented like:

将术语与文档相关联的更多SQL方法是1对多关系。这实现如下:

table term: columns term_id, term, document_id
table document: columns document_id, summary, ...

The document_id column in the term table is called a foreign key.

术语表中的document_id列称为外键。

#2


5  

I didn't find any limitation in number of elements in array, but there is in field size. Maximum size of field in PostgreSQL is 1GB, so it is approximately 268435456 elements in array. Be aware that indexing such array or searching through it would probably be useless.

我没有发现数组中元素数量有任何限制,但有字段大小。 PostgreSQL中字段的最大大小为1GB,因此它在数组中大约为268435456个元素。请注意,索引此类数组或搜索它可能是无用的。