Search Postgresql Archives

Re: SQL Programming Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 On 09/11/10 12:26 PM, Merlin Moncure wrote:
On Fri, Sep 10, 2010 at 11:07 PM,<tony@xxxxxxxxxxxxxxxxxxx>  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.



--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux