Re: SQL Programming Question

From: John R Pierce <pierce(at)hogranch(dot)com>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL Programming Question
Date: 2010-09-11 19:34:40
Message-ID: 4C8BD9D0.8010506@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/11/10 12:26 PM, Merlin Moncure wrote:
> On Fri, Sep 10, 2010 at 11:07 PM,<tony(at)exquisiteimages(dot)com> wrote:
>> Using PostgreSQL I can't open a table and do seeks against an index. I
>> could do a select against the database and see if 0 records are returned,
>> but that seems to take more time than doing a seek on an index. Is there a
>> more SQL friendly way of handling this task?
> I come a foxpro background too, and I can tell you for sure postgres
> indexes should give you similar performance to what you're used to.
> Do you have an index on the table?
>
>

again, the table should have either a primary key on this field, or a
unique constraint (a primary key is by definition unique)

BEGIN transaction
INSERT row
If Constraint Violation,
ROLLBACK transaction
INSERT row into exceptions table
ELSE
COMMIT transaction

(thats pseudocode)

if you want to do it faster, you batch multiple inserts in a single
transaction, using savepoints before each insert and rollback the
savepoint on the exception.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gabe Nell 2010-09-11 21:21:55 Incrementally Updated Backups
Previous Message Merlin Moncure 2010-09-11 19:26:22 Re: SQL Programming Question