Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C6BDA475E8C for ; Tue, 17 Sep 2002 06:14:52 -0400 (EDT) Received: from anchor-post-39.mail.demon.net (anchor-post-39.mail.demon.net [194.217.242.80]) by postgresql.org (Postfix) with ESMTP id 4D110475E6F for ; Tue, 17 Sep 2002 06:14:52 -0400 (EDT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-39.mail.demon.net with esmtp (Exim 3.36 #2) id 17rFNd-0004FC-0U; Tue, 17 Sep 2002 11:14:54 +0100 Received: from client.archonet.com (unknown [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id C96C917AAC; Tue, 17 Sep 2002 11:08:36 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: , Subject: Re: Dublicates pairs in a table. Date: Tue, 17 Sep 2002 11:07:33 +0100 User-Agent: KMail/1.4.1 References: <000201c25e14$921a9e10$6500000a@IT000> In-Reply-To: <000201c25e14$921a9e10$6500000a@IT000> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200209171107.33845.dev@archonet.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/190 X-Sequence-Number: 9467 On Tuesday 17 Sep 2002 7:36 am, Ries van Twisk wrote: > Richard, > > do you suggest using a stored procedure to handle this? I do expect that > the table will be large (for me large is a around 10000-20000 records, the > table as more columns but I only need the restriction on c1 & c2) but I > don=92t expect lots of inserts and deletes. Data entry will be done using= a > regular user but of course a update needs to be done within a acceptable > time so the user does not get annoyed. I'd go with the UNIQUE INDEX. You're unlikely to be able to write code any= =20 faster than the built-in indexing code. It's also simpler and easier for=20 someone else to see what's going on. The only time the index will slow you down is on an insert/delete when the= =20 index needs to be updated as well as the table. However, without the index= =20 you'll need to scan the table to check for duplicates. For thousands of=20 records that can only be slower. To put your mind at ease, I'd put together some test data and try it - noth= ing=20 like seeing some real evidence. HTH - Richard Huxton