Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TDFAR-0003vz-Et for pgsql-performance@postgresql.org; Sun, 16 Sep 2012 13:45:47 +0000 Received: from mail-pz0-f46.google.com ([209.85.210.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TDFAN-0007CG-Ad for pgsql-performance@postgresql.org; Sun, 16 Sep 2012 13:45:46 +0000 Received: by dady13 with SMTP id y13so318355dad.19 for ; Sun, 16 Sep 2012 06:45:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=jatXrPV+LS9+UWvyrFbiGVITOLvUG7dFoeRkPwLqJuk=; b=NQN2Vc6InX1Hju5XO4k42izTSA3NmTLALy0KtLifVYWI8HrbJeUYFAN8MTp0v9ElVt 9Z3nu6exB4BkSwZHTT+thssG7GF4tCxoJchpu2XwUMVy5qqnqq5jEMrnxwTFhpB4l/lb zeyMKQfIRWvlzx6tNK/UzGGywi0SaF8xA8S/81fbHCLLUJRcIqg3z5L+j/KoqIe4tERF jG0ucs/Y2ZZSK/04vo9qJxqzdCLFhkePSIrGWBfLM+lO/1Hq8fYV2UMZo0bwUvs4R0gC TFswD0tH8jAsT6FWkouGfDsgy4dZv6kvNPZIEInBZIbvpjj8n9it+H7GwPBgKZOafJDZ 938w== Received: by 10.68.195.226 with SMTP id ih2mr16536661pbc.9.1347803140934; Sun, 16 Sep 2012 06:45:40 -0700 (PDT) Received: from ayaki.localdomain (124-169-33-9.dyn.iinet.net.au. [124.169.33.9]) by mx.google.com with ESMTPS id nt7sm5059887pbb.33.2012.09.16.06.45.37 (version=SSLv3 cipher=OTHER); Sun, 16 Sep 2012 06:45:39 -0700 (PDT) Message-ID: <5055D7FF.2070908@ringerc.id.au> Date: Sun, 16 Sep 2012 21:45:35 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: "McKinzie, Alan (Alan)" CC: "pgsql-performance@postgresql.org" Subject: Re: Are there known performance issues with defining all Foreign Keys as deferrable initially immediate References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQl3tHu3nxKoGQ5wpTZOnbEH6XCxfn9RYqDdWKT0estkFyo0F2nAPftqv44ZPw68CG9Vk1ew X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201209/78 X-Sequence-Number: 47824 On 09/14/2012 11:56 PM, McKinzie, Alan (Alan) wrote: > My underlying question/concern is "will this change have any adverse > affects (on performance) during normal operations when the foreign keys > are set to deferrable initially immediate" .vs. the foreign keys being > defined as NOT DEFERRABLE. AFAIK in PostgreSQL DEFERRABLE INITIALLY IMMEDIATE is different to NOT DEFERRABLE. DEFERRABLE INITIALLY IMMEDIATE is executed at the end of the statement, while NOT DEFERRABLE is executed as soon as it arises. http://www.postgresql.org/docs/current/static/sql-set-constraints.html http://stackoverflow.com/questions/10032272/constraint-defined-deferrable-initially-immediate-is-still-deferred Again from memory there's a performance cost to deferring constraint checks to the end of the statement rather than doing them as soon as they arise, so NOT DEFERRED can potentially perform better or at least not hit limits that DEFERRABLE INITIALLY DEFERRED might hit in Pg. This seems under-documented and I haven't found much good info on it, so the best thing to do is test it. -- Craig Ringer