X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id 50ECD11F6AF1 for ; Tue, 11 Apr 2006 23:56:53 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -1.121 X-Spam-Level: X-Spam-Status: No, score=-1.121 required=5 tests=[AWL=1.480, BAYES_00=-2.599, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id wRZ6Y7kDtLnY for ; Tue, 11 Apr 2006 23:56:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 9C0D611F6AE3 for ; Tue, 11 Apr 2006 23:56:45 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3C2uhHY013088; Tue, 11 Apr 2006 22:56:43 -0400 (EDT) To: "Jim C. Nasby" cc: Michael Glaesemann , Rodrigo Sakai , pgsql-performance@postgresql.org Subject: Re: FOREIGN KEYS vs PERFORMANCE In-reply-to: <20060411233820.GB49405@pervasive.com> References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> <20060411233820.GB49405@pervasive.com> Comments: In-reply-to "Jim C. Nasby" message dated "Tue, 11 Apr 2006 18:38:20 -0500" Date: Tue, 11 Apr 2006 22:56:43 -0400 Message-ID: <13087.1144810603@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200604/256 X-Sequence-Number: 18340 "Jim C. Nasby" writes: > On Wed, Apr 12, 2006 at 08:06:17AM +0900, Michael Glaesemann wrote: >> ... 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. > It's also pretty unlikely that you can make RI in the application > perform better than in the database. I think the traditional assumption among the "you should do RI in the application" crowd is that the application has higher-level knowledge that lets it understand when it can skip doing an RI check entirely. Skipping an RI check is always faster than doing it --- so that's right, it's faster. As long as you don't make any mistakes. The question you have to ask yourself is whether you are really that smart ... not just today, but every single time. To quote Clint Eastwood: "Do you feel lucky punk? Well, do you?" regards, tom lane