agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: AlexK <alkuzo@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Is there an upper limit on the size of an array if it is indexed?
Date: Mon, 24 Feb 2014 15:39:55 -0500
Message-ID: <9198.1393274395@sss.pgh.pa.us> (raw)
In-Reply-To: <1393273817988-5793380.post@n5.nabble.com>
References: <1393273817988-5793380.post@n5.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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



view thread (4+ messages)  latest in thread

Message-ID: <9198.1393274395@sss.pgh.pa.us>
Permalink:  ../9198.1393274395@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9198.1393274395@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, alkuzo@gmail.com
  Subject: Re: Is there an upper limit on the size of an array if it is indexed?
  In-Reply-To: <9198.1393274395@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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