Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQuvg-00079z-4p for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Apr 2020 15:35:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQuvf-0007no-1c for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Apr 2020 15:35:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQuve-0007nh-R9 for pgsql-hackers@lists.postgresql.org; Tue, 21 Apr 2020 15:35:18 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jQuvX-0003PE-Rz for pgsql-hackers@postgresql.org; Tue, 21 Apr 2020 15:35:18 +0000 Received: by mail-qk1-x742.google.com with SMTP id j4so14880403qkc.11 for ; Tue, 21 Apr 2020 08:35:11 -0700 (PDT) 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=c+wsOckO+u53BedK3FDs+WxAC1b63dOzzXdMo87XJks=; b=soeWoTcVe1pfaZqgWd5gM1mwM+tW4oCHaseY9wMS/hojmPsHyDMkbV+SCojxlwoabT GoUT+ws6jEYQKqIyy2Nq/cUEmLe/ht5hdeprUnJi/KbXLyhBQ6Kkomj/y8tWW09yzrY+ qJyU7ybs/Lk4pELrlxJdU9LYUzupOCUvXbTQJjq48znrNSr+7VsSHGAwXGbZmGJpZ0pW OQqi561B17RGQIobrJ1KJPZx6c6jDc/I/C7TMi61UW2KpyTBeKQgKycyx6f7c58qTHY8 EwKsfDPLdU6YOEWqDb2a4XhKIAu/XlMmbJoK2f6fH4Fvg6nX0b12WmTpVJ/+nVjSti4v 0E6w== 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=c+wsOckO+u53BedK3FDs+WxAC1b63dOzzXdMo87XJks=; b=LFhiPT9lHsUshBJUy24rg5neJvzCbXmjfaw8ltZ4luY02jkzY3fp6mf10daz84QLVE RVgyVou8RQ7HksE8a3VFk+RgGNPkUvSOkga/+uuyU0RQfxj4qlWIkzRBqyZ9zXVMj0Lm y0cA5m3iUQRvAGD1um1LkhWitaWs/lwN6ClgwBQJM9etRsoLST5z3VBwidfPlzt9XDe/ JvrFmbdehNkJg3qtB3wkPDbpzFhzvTahCwEJ7jqHtRvkAWhbLTp5zrQxgyBkJf+GtkUZ 9SRs7X5j449f0dX5G/K0bP87V39o/zaAXzQ8f1UjJTJdou36SKjCt8CGuUSTFK68wRll RpCA== X-Gm-Message-State: AGi0PuY4EppkHUkXXSaWT3VNqz/Plt6/CrqEyZOIS/BqCKUVu9HrkOjd l6lWH9DRViQ7DYHmgSyVVo88ZQ== X-Google-Smtp-Source: APiQypKwoSgXBJXaiW/9Fz3zFyrTgZTFnOAHBZxIe57Cnhl+SGpZUbf7+tomBSTXPj4jwVSXtYGNBg== X-Received: by 2002:a37:6d2:: with SMTP id 201mr22163009qkg.154.1587483310454; Tue, 21 Apr 2020 08:35:10 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id v5sm1910876qka.106.2020.04.21.08.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 08:35:09 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 71EA3301985; Tue, 21 Apr 2020 11:34:54 -0400 (-04) Date: Tue, 21 Apr 2020 11:34:54 -0400 From: Alvaro Herrera To: Corey Huinker Cc: Antonin Houska , Pavel Stehule , PostgreSQL Hackers Subject: Re: More efficient RI checks - take 2 Message-ID: <20200421153454.GA19350@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: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Apr-20, Corey Huinker wrote: > > I can imagine removal of the SPI from the current implementation (and > > constructing the plans "manually"), but note that the queries I use in my > > patch are no longer that trivial. So the SPI makes sense to me because it > > ensures regular query planning. > > As an intermediate step, in the case where we have one row, it should be > simple enough to extract that row manually, and do an SPI call with fixed > values rather than the join to the ephemeral table, yes? I do wonder if the RI stuff would actually end up being faster without SPI. If not, we'd only end up writing more code to do the same thing. Now that tables can be partitioned, it is much more of a pain than when only regular tables could be supported. Obviously without SPI you wouldn't *have* to go through the planner, which might be a win in itself if the execution tree to use were always perfectly clear ... but now that the queries get more complex per partitioning and this optimization, is it? You could remove the crosscheck_snapshot feature from SPI, I suppose, but that's not that much code. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services