Re: FOREIGN KEYS vs PERFORMANCE

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Rodrigo Sakai <rodrigo(dot)sakai(at)zanthus(dot)com(dot)br>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: FOREIGN KEYS vs PERFORMANCE
Date: 2006-04-11 19:48:46
Message-ID: 1144784926.32269.88.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, 2006-04-11 at 14:13, Rodrigo Sakai wrote:
> Hi,
>
> I think this is an old question, but I want to know if it really is
> well worth to not create some foreign keys an deal with the
> referential integrity at application-level?????
> Specifically, the system we are developing is a server/cliente
> architecture that the server is the database and the fat client is an
> application developed in DELPHI!!!
>

If ref integrity is important, you'll have to do it either in the app or
the database.

Almost always, it's faster to let the database do it, as there's less
traffic across the wire required to maintain ref integrity, plus, the
guys who wrote the database have spent years making sure race conditions
won't scram your data.

For simple, straight forward FK->PK relationships, you will likely NOT
be able to beat the database in terms of either reliability or
performance with your own code.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Dan Harris 2006-04-11 20:59:22 Re: Encouraging multi-table join order
Previous Message Rodrigo Sakai 2006-04-11 19:13:34 FOREIGN KEYS vs PERFORMANCE