Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WI2Jo-0001T0-Nn for pgsql-sql@arkaria.postgresql.org; Mon, 24 Feb 2014 20:40:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WI2Jo-0000zD-6m for pgsql-sql@arkaria.postgresql.org; Mon, 24 Feb 2014 20:40:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WI2Jn-0000z6-5q for pgsql-sql@postgresql.org; Mon, 24 Feb 2014 20:40:03 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WI2Jg-0007o5-Po for pgsql-sql@postgresql.org; Mon, 24 Feb 2014 20:40:02 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s1OKdtX3009199; Mon, 24 Feb 2014 15:39:55 -0500 From: Tom Lane To: AlexK cc: pgsql-sql@postgresql.org Subject: Re: Is there an upper limit on the size of an array if it is indexed? In-reply-to: <1393273817988-5793380.post@n5.nabble.com> References: <1393273817988-5793380.post@n5.nabble.com> Comments: In-reply-to AlexK message dated "Mon, 24 Feb 2014 12:30:18 -0800" Date: Mon, 24 Feb 2014 15:39:55 -0500 Message-ID: <9198.1393274395@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org AlexK 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