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 1jRVLP-0001ab-Rt for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Apr 2020 06:28: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 1jRVLO-0004vz-Dn for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Apr 2020 06:28:18 +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 1jRVLO-0004vs-25 for pgsql-hackers@lists.postgresql.org; Thu, 23 Apr 2020 06:28:18 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jRVLJ-0000Ik-Ln for pgsql-hackers@postgresql.org; Thu, 23 Apr 2020 06:28:16 +0000 Received: by mail-wm1-x331.google.com with SMTP id u16so5235488wmc.5 for ; Wed, 22 Apr 2020 23:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:in-reply-to:references:comments:mime-version :content-transfer-encoding:date:message-id; bh=qbQhGdZFOlYT/xLRMm+DvA6lDsGRA8X4Wi3HXLyyaRg=; b=OGidnUMMJc6zNySJxHKZdgoKXbiIOFFI/pFbXofNenLDVMWKr6293p3NIVcwRFJwEZ BYAX2Olp2oiOUzedBf2WRf0UmnS3i72evDdkV6AgBn6A5hEH/jcSxiIB62CvgvnqJw2S XyxoWAFTNi/0IwfNhaWk7ZbqWpckvqXs4YicAuqSEsBanVpo3vWjGfHsVqgT0pAbwt7s CbgnlvHc8zf+n0R5dWX6YJdWvuY6QMnWUFGhv4yec67olyKIWYj7lhlUQHh3cWmsihkJ //4Wo7ymZro9Irx6nnxC29iLSyg21jhQIniC9VsUkI9S7B/5GOotFXo2puxFK0ifHBZD TOpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :comments:mime-version:content-transfer-encoding:date:message-id; bh=qbQhGdZFOlYT/xLRMm+DvA6lDsGRA8X4Wi3HXLyyaRg=; b=Q18DSTB8oPB4h3nCSgSWRPxSS86hxyX0E+81TV0SwCyHjt1jO2BhRI6DHbgKCIEjDd P7HyaNqEqXH8sbu3fzd9VpLOdIGD9NbcKALOlrP882WhUH6PiPfqzdV8RoD9zONSni8/ 3SzhfBYnjMBNfDAi+MlTsqZdArkD+se74ONqMA/kDxE7FBEYvs7ls529tvLPt5iMIAtn PiNrhiV7/qddrrtXYIJDkFyOruoZoyu6ijdupaHv8w+nfL9HVXis9MwhLRkR/WnkgG8r C1l4OdhrNrg8qkG9Qa4AmlGAqVver+PEzs+Of+BGMUU4d8f2VMACOuQgW7DHyR1hBxFC 9CnQ== X-Gm-Message-State: AGi0PubwB64f3G2TWKGeI9SZP6G3s8axCayMNZCvPoSJqf2JdCxdmsrp 9LqPUKkjAj/4KRSUlhaCxZ8azA== X-Google-Smtp-Source: APiQypLcuE2onJpBtm7tvCjfT9uHFQD//4h4yG07fD97tsCtvSVqddkxi1XWgz5EXThrq3+56O+80A== X-Received: by 2002:a1c:e087:: with SMTP id x129mr2357395wmg.127.1587623291899; Wed, 22 Apr 2020 23:28:11 -0700 (PDT) Received: from antos ([77.87.240.5]) by smtp.gmail.com with ESMTPSA id z8sm2121878wrr.40.2020.04.22.23.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2020 23:28:10 -0700 (PDT) From: Antonin Houska To: Pavel Stehule cc: Tom Lane , Robert Haas , Andres Freund , Alvaro Herrera , Corey Huinker , PostgreSQL Hackers Subject: Re: More efficient RI checks - take 2 In-reply-to: References: <20200422154231.6shz4kdor4yb5w5b@alap3.anarazel.de> <20200422171806.GA12435@alvherre.pgsql> <20200422183600.tpl5745dfbnozi6t@alap3.anarazel.de> <6442.1587595207@sss.pgh.pa.us> <28826.1587618482@antos> Comments: In-reply-to Pavel Stehule message dated "Thu, 23 Apr 2020 07:13:40 +0200." X-Mailer: MH-E 8.6+git; nmh 1.7; GNU Emacs 26.3.50 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 23 Apr 2020 08:29:33 +0200 Message-ID: <29560.1587623373@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Pavel Stehule wrote: > =C4=8Dt 23. 4. 2020 v 7:06 odes=C3=ADlatel Antonin Houska napsal: >=20 > Tom Lane wrote: >=20 > > But it's not entirely clear to me that we know the best plan for a > > statement-level RI action with sufficient certainty to go that way. > > Is it really the case that the plan would not vary based on how > > many tuples there are to check, for example? >=20 > I'm concerned about that too. With my patch the checks become a bit slow= er if > only a single row is processed. The problem seems to be that the planner= is > not entirely convinced about that the number of input rows, so it can st= ill > build a plan that expects many rows. For example (as I mentioned elsewhe= re in > the thread), a hash join where the hash table only contains one tuple. Or > similarly a sort node for a single input tuple. >=20 > without statistics the planner expect about 2000 rows table , no? I think that at some point it estimates the number of rows from the number = of table pages, but I don't remember details. I wanted to say that if we constructed the plan "manually", we'd need at le= ast two substantially different variants: one to check many rows and the other = to check a single row. --=20 Antonin Houska Web: https://www.cybertec-postgresql.com