X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id D32EB11F6632 for ; Wed, 12 Apr 2006 10:18:45 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.12 X-Spam-Level: X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id VYuqahP37JqU for ; Wed, 12 Apr 2006 10:18:39 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (unknown [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 182AB11F6065 for ; Wed, 12 Apr 2006 10:18:43 -0300 (ADT) Received: from kingfisher.intern.logix-tt.com (T9c8e.t.pppool.de [89.55.156.142]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 51E51657E1; Wed, 12 Apr 2006 15:19:37 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 0786C181C1E89; Wed, 12 Apr 2006 15:18:56 +0200 (CEST) Message-ID: <443CFE3F.5090304@logix-tt.com> Date: Wed, 12 Apr 2006 15:18:55 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Cc: Rodrigo Sakai Subject: Re: FOREIGN KEYS vs PERFORMANCE References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> In-Reply-To: <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Archive-Number: 200604/261 X-Sequence-Number: 18345 Hi, Michael, Hi, Rodrigo, Michael Glaesemann wrote: > If I had to choose between one or the other, I'd leave all referential > integrity in the database and deal with the errors thrown when > referential integrity is violated in the application. PostgreSQL is > designed to handle these kinds of issues. Anything you code in your > application is more likely to contain bugs or miss corner cases that > would allow referential integrity to be violated. PostgreSQL has been > pounded on for years by a great many users and developers, making the > likelihood of bugs still remaining much smaller. I strictly agree with Michael here. > Of course, you can add some referential integrity checks in your > application code, but those should be in addition to your database- > level checks. Agree. It does make sense to have reference checks in the UI or application level for the sake of better error handling, but the database should be the mandatory judge. There's another advantage of database based checking: Should there ever be the need of a different application working on the same database (e. G. an "expert level UI", or some connector that connects / synchronizes to another software, or a data import tool), database based constraints cannot be broken opposed to application based ones. HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org