pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: ries@jongert.nl
To: pgsql-sql@postgresql.org
Subject: Re: Dublicates pairs in a table.
Date: Tue, 17 Sep 2002 11:07:33 +0100
Message-ID: <200209171107.33845.dev@archonet.com> (raw)
In-Reply-To: <000201c25e14$921a9e10$6500000a@IT000>
References: <000201c25e14$921a9e10$6500000a@IT000>

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’t 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 
faster than the built-in indexing code. It's also simpler and easier for 
someone else to see what's going on.

The only time the index will slow you down is on an insert/delete when the 
index needs to be updated as well as the table. However, without the index 
you'll need to scan the table to check for duplicates. For thousands of 
records that can only be slower.

To put your mind at ease, I'd put together some test data and try it - nothing 
like seeing some real evidence.

HTH

- Richard Huxton



view thread (10+ messages)  latest in thread

Message-ID: <200209171107.33845.dev@archonet.com>
Permalink:  ../200209171107.33845.dev@archonet.com/
Also on:    postgresql.org/message-id/200209171107.33845.dev@archonet.com

 · 

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: dev@archonet.com, ries@jongert.nl
  Subject: Re: Dublicates pairs in a table.
  In-Reply-To: <200209171107.33845.dev@archonet.com>

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

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