| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | AlexK <alkuzo(at)gmail(dot)com> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Is there an upper limit on the size of an array if it is indexed? |
| Date: | 2014-02-24 20:39:55 |
| Message-ID: | 9198.1393274395@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
AlexK <alkuzo(at)gmail(dot)com> writes:
> I have created a unique index on an array of integers, and it works for a
> small test case:
> create table i(id int not null primary key,
> v int[] not null unique );
> insert into i(id, v) values(1, ARRAY[1,2]);
> -- fails
> insert into i(id, v) values(2, ARRAY[1,2]);
> -- succeeds
> insert into i(id, v) values(2, ARRAY[2,1]);
> Is there an upper limit on the size of an array being indexed? I am
> currently considering arrays of 2K-3K integers.
PG btrees have an item size limit of a couple of KB, so I don't think
this is going to work well for you.
Some people have gotten around that by using a unique index on a hash
value. If you use something like MD5, the odds of a false collision
are probably low enough to tolerate.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | AlexK | 2014-02-24 20:43:53 | Re: Is there an upper limit on the size of an array if it is indexed? |
| Previous Message | Rob Sargent | 2014-02-24 20:35:08 | Re: Is there an upper limit on the size of an array if it is indexed? |