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 A2B3811F696C for ; Wed, 12 Apr 2006 12:08:57 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -2.414 X-Spam-Level: X-Spam-Status: No, score=-2.414 required=5 tests=[AWL=0.050, BAYES_00=-2.599, FORGED_RCVD_HELO=0.135] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id 5A5fNm1QGbw2 for ; Wed, 12 Apr 2006 12:08:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) by postgresql.org (Postfix) with ESMTP id 7267711F694F for ; Wed, 12 Apr 2006 12:08:46 -0300 (ADT) Received: (qmail 30442 invoked from network); 12 Apr 2006 17:09:41 +0200 Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) by boutiquenumerique.com with SMTP; 12 Apr 2006 17:09:41 +0200 Date: Wed, 12 Apr 2006 17:09:37 +0200 To: "Rodrigo Sakai" , pgsql-performance@postgresql.org Subject: Re: FOREIGN KEYS vs PERFORMANCE References: <001301c65d9c$08884ef0$4700a8c0@TREEZANTHUS> <72C39159-1A4B-4595-A978-1DF57AD42527@myrealbox.com> <443CFE3F.5090304@logix-tt.com> <000701c65e40$5a1ff700$4700a8c0@TREEZANTHUS> From: PFC Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <000701c65e40$5a1ff700$4700a8c0@TREEZANTHUS> User-Agent: Opera M2/8.51 (Linux, build 1462) X-Archive-Number: 200604/266 X-Sequence-Number: 18350 What kinds of operations are made slow by foreign key checks ? Is it : - Simple checks on INSERT ? - Simple checks on UPDATE ? - Cascaded deletes ? - Cascaded updates ? - Locks ? - Something else ? Foreign keys are to ensure that the value in a column is always part of a specific set (the referenced table). If this set changes very rarely, like the list of countries in the world, or the list of states in a country, or the various possible states an order can be in (received, processed, shipped...) then it's alright to skip the check if you're sure your application will insert a valid value. For some other situations, doing the check in the application will need some queries and could be slower (and certainly will be more complicated...) Are you sure you're not missing a few indexes, which would then force fkey checks to use sequential scans ? > Thanks for all help!! But my problem is with performance, I agree with > all > of you, the RI must be maintained by the database, because a bunch of > reasons that everyone knows! > But, I'm dealing with a very huge database that servers more than 200 > clientes at the same time, and because of it, each manipulation (delete, > insert, update, select) on the database have a poor performance. So, if > we > deal with RI in each client station, we take this work off the database! > The application is an ERP developed with DELPHI + (postgresql or > oracle or > sql server)!!