agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
Is there an upper limit on the size of an array if it is indexed?
4+ messages / 3 participants
[nested] [flat]

* Is there an upper limit on the size of an array if it is indexed?
@ 2014-02-24 20:30 AlexK <alkuzo@gmail.com>
  2014-02-24 20:35 ` Re: Is there an upper limit on the size of an array if it is indexed? Rob Sargent <robjsargent@gmail.com>
  2014-02-24 20:39 ` Re: Is there an upper limit on the size of an array if it is indexed? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 4+ messages in thread

From: AlexK @ 2014-02-24 20:30 UTC (permalink / raw)
  To: pgsql-sql

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.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/Is-there-an-upper-limit-on-the-size-of-an-array-if-it-is-ind...
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Is there an upper limit on the size of an array if it is indexed?
  2014-02-24 20:30 Is there an upper limit on the size of an array if it is indexed? AlexK <alkuzo@gmail.com>
@ 2014-02-24 20:35 ` Rob Sargent <robjsargent@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Rob Sargent @ 2014-02-24 20:35 UTC (permalink / raw)
  To: pgsql-sql

On 02/24/2014 01:30 PM, AlexK wrote:
> 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.
>
>
>
What are the odds?  Might be worth the risk.

rjs



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Is there an upper limit on the size of an array if it is indexed?
  2014-02-24 20:30 Is there an upper limit on the size of an array if it is indexed? AlexK <alkuzo@gmail.com>
@ 2014-02-24 20:39 ` Tom Lane <tgl@sss.pgh.pa.us>
  2014-02-24 20:43   ` Re: Is there an upper limit on the size of an array if it is indexed? AlexK <alkuzo@gmail.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Tom Lane @ 2014-02-24 20:39 UTC (permalink / raw)
  To: AlexK <alkuzo@gmail.com>; +Cc: pgsql-sql

AlexK <alkuzo@gmail.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


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Is there an upper limit on the size of an array if it is indexed?
  2014-02-24 20:30 Is there an upper limit on the size of an array if it is indexed? AlexK <alkuzo@gmail.com>
  2014-02-24 20:39 ` Re: Is there an upper limit on the size of an array if it is indexed? Tom Lane <tgl@sss.pgh.pa.us>
@ 2014-02-24 20:43   ` AlexK <alkuzo@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: AlexK @ 2014-02-24 20:43 UTC (permalink / raw)
  To: pgsql-sql

Tom, is this limitation documented anywhere?



--
View this message in context: http://postgresql.1045698.n5.nabble.com/Is-there-an-upper-limit-on-the-size-of-an-array-if-it-is-ind...
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2014-02-24 20:43 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-02-24 20:30 Is there an upper limit on the size of an array if it is indexed? AlexK <alkuzo@gmail.com>
2014-02-24 20:35 ` Rob Sargent <robjsargent@gmail.com>
2014-02-24 20:39 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-02-24 20:43   ` AlexK <alkuzo@gmail.com>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox