Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYwgF-0007bD-QT for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Dec 2018 17:27:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gYwgE-00073k-GV for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Dec 2018 17:27:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYwgE-00073c-9c for pgsql-hackers@lists.postgresql.org; Mon, 17 Dec 2018 17:27:46 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYwgB-0002ud-IQ for pgsql-hackers@postgresql.org; Mon, 17 Dec 2018 17:27:45 +0000 Received: by mail-qk1-x743.google.com with SMTP id w204so7810768qka.2 for ; Mon, 17 Dec 2018 09:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=n0Kw8JDtwGhFLz3ZSua/aretN8nptWBwiAJ/9rHNoOQ=; b=fXOMi3CQ0mRwyyIeA9vh08u+p97HLshiiNZMsZgrD36I1G50lP2hDSGEDzGE7cU0tz g4+4vB4JrmcmJ9puUZtbfsyguMXYl4UW/MDtwQRXPt7yMZjnMI3O9b+GbHktspXWbJu4 hNB8iudPS2pFt8y4M2R2+DmP50xiCwjF0IAkOLf+PruitCjl0JoZ2MoVGKJmkVI8NV+T gSwbPkiEJtn7ZqIx6LzjzYGIZuBjYoa136/oeFvj5mFiqLHEIKTljC2B18rtdFT48M5/ O5pjWLd3jH7J73izDjqxsXLnaylXhy3sbr3NDF/DHf+5Djv8b/1WpNo0d0HiRr0lKwLB BvSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=n0Kw8JDtwGhFLz3ZSua/aretN8nptWBwiAJ/9rHNoOQ=; b=cs1DLfosPn1BDOQzHeqqVzJnTWU/v444mZEELyjg1aXs0v5DGLq5hHPufr92uSkSrV f+ZTPfgmwHsaBKb/FmVXceZA9ZFsasduSz2Uj1g9pJloqBCHSF6JyYMQtHe+Mz9HL9or NYhQACTJ2YXIyYDM5PZ8ykmvHJNGU5OkWlnXW6PmSyc1j3b/1lDtm8SdWyXxmFVsQAAh mZ3W3s1f94IrC2ENLWzCgfJy5hctZtaSLlAOctGymYDY98j6nca5UsO43l+YwEau2fpp PH3mlBXabxPjtrUKqdsIeCApL/fYRFmPfaFEvIZG43zhTA+F6BTOxBKWq6iy3gHWMWKY HT/A== X-Gm-Message-State: AA+aEWbQA2pJWfo9B5AOLwmPttb/J3PGQat/MRMAa2wTOvZclNRYNoAx RONLCXYZ3CmQJRXa1P2PQkdJLQ== X-Google-Smtp-Source: AFSGD/UnOj+9H+NQuu0N4aE59amb0B4jKHRiDPtIt2SDsMNhlr9a9pvhYNlN3MgMiS5+aGFrLLTAPw== X-Received: by 2002:a37:27d2:: with SMTP id n201mr12906941qkn.63.1545067662035; Mon, 17 Dec 2018 09:27:42 -0800 (PST) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id c77sm10614824qkh.82.2018.12.17.09.27.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Dec 2018 09:27:41 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 8EE2F958; Mon, 17 Dec 2018 14:27:29 -0300 (-03) Date: Mon, 17 Dec 2018 14:27:29 -0300 From: Alvaro Herrera To: Pavel Stehule Cc: Corey Huinker , PostgreSQL Hackers Subject: Re: Referential Integrity Checks with Statement-level Triggers Message-ID: <20181217172729.mjfkflaelii2boaj@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Dec-17, Pavel Stehule wrote: > ROW trigger call RI check too often, and statement trigger too less. I > think so ideal design can be call RI check every 10K rows. I think so can > be unfriendly if somebody does very long import and it fails on the end. I > don't think so there should not be any performance difference, if RI check > is called per 1000 or more rows. This is a good point, but I'm not sure if it's possible to implement using statement-level triggers. I think the way transition tables work is that you get the full results at the end of the command; there's no way to pass control to the RI stuff at arbitrary points during the execution of the command. Is there any guidance on the SQL standard about this? I don't think the timing indicators in the standard (IMMEDIATE, DEFERRED) have any say on this. Or do they? Maybe there is a solution for this. I think it's worth thinking about, even if it's just to say that we won't do it. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services