English 中文(简体)
Postgress 阵列阵列
原标题:Postgres Arrays

我们正在使用“https://github.com/ecoterma/django-dbarray” rel=“nofollow”>django-dbarray 模块来使用后格列中的阵列。 我一直在对后格列阵列做一些研究, 一些开发者说, 他们不建议使用存储在X值之上的后格阵列。 有时, 这是10个, 我听了多达30个。 对于在性能开始缩小之前有多少值可以或应该存储在阵列中, 是否有共识?

" 参考 ",上述DB主要为 " DB ",仅读为 " DB " 。

我们正试图决定我们在哪里应该使用中间表格,在哪里应该使用后gres阵列。

另一个相关的问题是:在对表格中的一列创建索引时,该列存储数组值(不说大数组 ) 。 我知道数组中存储的值不会被索引化,而只是数组本身(我假定这类似于C指针 ) 。 与仅仅有一个中间表相比,这有多有效?

我们可能需要建立违背价值观的组合,或者在条款中加入某些具体价值观,我担心有些表现会退化,我们最好在需要建立联合时有一个中间桌。

最后,鉴于我们使用的是Dbarray,那么仅仅使用标准对接ORM的中间桌子(假定不加入就是上述问题的条款),效率又如何?

谢谢

最佳回答

PostgreSQL 支持 GIN GiST 索引, 从而可以运行这样的查询:

SELECT  *
FROM    mytable
WHERE   myarray @> ARRAY[1, 2]
-- returns arrays which contain 1 AND 2

或此:

SELECT  *
FROM    mytable
WHERE   myarray && ARRAY[1, 2]
-- returns arrays which contain 1 OR 2

效率高。

第一个查询有点难以使用正常的公式来有效重写。

问题回答

暂无回答




相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签