Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 0DBFD47645C; Mon, 20 May 2002 18:10:20 -0400 (EDT) Mailbox-Line: From andre@liquidprivacy.net Mon May 20 18:10:20 2002 Received: from pepe.lfcity.org (sanpedro-a649.racsa.co.cr [196.40.42.144]) by postgresql.org (Postfix) with ESMTP id AB3094763C4; Mon, 20 May 2002 17:13:38 -0400 (EDT) Received: from there (localhost.localdomain [127.0.0.1]) by pepe.lfcity.org (Postfix) with SMTP id A3F8A80269; Mon, 20 May 2002 15:17:09 -0500 (CDT) Content-Type: text/plain; charset="iso-8859-1" From: andre To: pgsql-sql@postgresql.org Subject: Guarantee uniqueness of PGP key Date: Mon, 20 May 2002 15:17:09 -0500 X-Mailer: KMail [version 1.3.1] Cc: pgsql-novice@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <20020520201709.A3F8A80269@pepe.lfcity.org> X-Spam-Status: Yes, hits=5.0 required=5.0 tests=RCVD_IN_OSIRUSOFT_COM, X_OSIRU_SPAM_SRC version=2.20 X-Spam-Flag: YES X-Spam-Level: ***** X-Spam-Checker-Version: SpamAssassin 2.20 (devel $Id: SpamAssassin.pm, v 1.77 2002/04/06 19:28:30 hughescr Exp $) X-Spam-Report: Detailed Report SPAM: -------------------- Start SpamAssassin results ---------------------- SPAM: This mail is probably spam. The original message has been altered SPAM: so you can recognise or block similar unwanted mail in future. SPAM: See http://spamassassin.org/tag/ for more details. SPAM: SPAM: Content analysis details: (5 hits, 5 required) SPAM: Hit! (2.0 points) Received via a relay in relays.osirusoft.com SPAM: [RBL check: found 144.42.40.196.relays.osirusoft.com., type: 127.0.0.4] SPAM: Hit! (3.0 points) DNSBL: sender is Confirmed Spam Source SPAM: SPAM: -------------------- End of SpamAssassin results --------------------- X-Archive-Number: 200205/202 X-Sequence-Number: 3832 Hi, More generically, how do I best guarantee that any large varchar is unique= =20 before inserting? In my application, I need to ensure that each e-mail address and=20 corresponding PGP public key are both unique. I originally implemented this by adding a uniqueness contrainst to both=20 columns. easy. The problem is that some PGP keys are over 2713 bytes, and postgres (7.2)= =20 gives the error: ERROR: btree: index item size 4336 exceeds maximum 2713 I thought perhaps I could use a hash or rtree index, but neither of them wo= rk=20 for unique-ness. I saw in another posting that it may be possible to raise this limit to 8k = or=20 so, but I don't want to do this because 1) it requires a recompile of=20 postgres (and rollout to dev, stage, prod machines), and 2) a key could=20 theoretically be longer than 8k anyway. I can guarantee unique-ness by removing the index and doing a select before= =20 the insert. If there is a matching row, then I am trying to insert a dup.= =20 bail. My concern is that doing this without an index will be monumentally slow fo= r=20 any large-ish number of keys. Any bright ideas? All suggestions appreciated. /andre