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 1kSZDJ-0007W8-Dz for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Oct 2020 05:20:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kSZDH-0007rV-OP for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Oct 2020 05:20:35 +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 1kSZDH-0007rN-Cl for pgsql-hackers@lists.postgresql.org; Wed, 14 Oct 2020 05:20:35 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kSZDD-0004K0-VC for pgsql-hackers@postgresql.org; Wed, 14 Oct 2020 05:20:35 +0000 Received: by mail-wr1-x443.google.com with SMTP id e18so2140049wrw.9 for ; Tue, 13 Oct 2020 22:20:31 -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-id:content-transfer-encoding:date:message-id; bh=LJQtLcTGTCUgcD9PE/1mOxLAgzrlCNxmT7KGS9Spn5M=; b=YEKkycFtc1URWo8K/LtcCC3WzWV3M9e6oohMzTlPUCdsaOgiVgVqKDHmzoheOcVkxN hfE20tpjN0t7Gna0RK211/DvzLjLmcYkV8IX+j21Ct8tKOLV6fC4+KP3mE4q5vYEjynF 1BQD7wRXF62z3eBhUUF0uVQps5Dx8u8m5Ouk45ciRDeDDteRnm10w/ZjapaEHUl/2G+5 h+qXHwZbFZgqVBr4XHop9xo9qQDjuCio9ij38agQQRQqOe9j1GcNha+7yOqtHvqQkvyv Vu8695bGGkNisHac/uq++Ciw4kWoM7mBHo1tF+uQuLk/2jPJpQ8JPOE2mo1WwzMYrvgs Yx4Q== 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-id:content-transfer-encoding:date :message-id; bh=LJQtLcTGTCUgcD9PE/1mOxLAgzrlCNxmT7KGS9Spn5M=; b=M2GvpjtcCY2GOQX+lGgntuK17AGlu+3+Uvk0DKdj3AgaM/hQWTeEWWd7brtw+PnIYb SyxmXDgt8uwvkiAoH8Yhfqtk7HyfV/GkQi4QBNuGNJPHMaCnBja6mCVukDeOzJcn+c2k hCeYrXv32z+gFy0v291qiF8mWAwSidFKPEIYoa2DkBQgZpW0thvEYcPzbQjRcNjTHxjK 3FX77Y+t/GuddAOzailGvnd5t4BqTpVEFof6K2THzLWHUE+VgJseFb3Dn5uvMTvQxUNy VU+daGXHd1H0zuZdq3a8X8O5Z5G2/NZCqysNCvRRm8sdltynbdAY4Oj390y68snpRgVc lajw== X-Gm-Message-State: AOAM533WIrPCekWOAFYjsolZyCazTBQB5FdjtrA0CryuOXifCzBIuO5s Uc1erBRvzIwFNp8s06bMT6ZYWg== X-Google-Smtp-Source: ABdhPJzX4A94pGIUfe/aKDOgYfFgNYayURwKGjKrKcbfuErr6UuqZixxpbODGD93OzKtaYLW7zdMog== X-Received: by 2002:adf:bbca:: with SMTP id z10mr3438337wrg.403.1602652830874; Tue, 13 Oct 2020 22:20:30 -0700 (PDT) Received: from antos (85-207-122-76.static.bluetone.cz. [85.207.122.76]) by smtp.gmail.com with ESMTPSA id 30sm2933969wrr.35.2020.10.13.22.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2020 22:20:30 -0700 (PDT) From: Antonin Houska To: Justin Pryzby cc: pgsql-hackers@postgresql.org, Andres Freund Subject: Re: More efficient RI checks - take 2 In-reply-to: <20200927025917.GB13816@telsasoft.com> References: <1813.1586363881@antos> <65467.1591370203@antos> <20200927025917.GB13816@telsasoft.com> Comments: In-reply-to Justin Pryzby message dated "Sat, 26 Sep 2020 21:59:17 -0500." X-Mailer: MH-E 8.6+git; nmh 1.7; GNU Emacs 26.3.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <57553.1602652953.1@antos> Content-Transfer-Encoding: quoted-printable Date: Wed, 14 Oct 2020 07:22:33 +0200 Message-ID: <57554.1602652953@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Justin Pryzby wrote: > I'm interested in testing this patch, however there's a lot of internals= to > digest. > = > Are there any documentation updates or regression tests to add ? I'm not sure if user documentation should be changed unless a new GUC or statistics information is added. As for regression tests, perhaps in the n= ext version of the patch. But right now I don't know how to implement the feat= ure in a less invasive way (see the complaint by Andres in [1]), nor do I have enough time to work on the patch. > If FKs support "bulk" validation, users should know when that applies, a= nd > be able to check that it's working as intended. Even if the test cases = are > overly verbose or not stable, and not intended for commit, that would be= a > useful temporary addition. > = > I think that calls=3D4 indicates this is using bulk validation. > = > postgres=3D# begin; explain(analyze, timing off, costs off, summary off,= verbose) DELETE FROM t WHERE i<999; rollback; > BEGIN > QUERY PLAN = > ----------------------------------------------------------------------- > Delete on public.t (actual rows=3D0 loops=3D1) > -> Index Scan using t_pkey on public.t (actual rows=3D998 loops=3D1) > Output: ctid > Index Cond: (t.i < 999) > Trigger RI_ConstraintTrigger_a_16399 for constraint t_i_fkey: calls=3D4 > I started thinking about this 1+ years ago wondering if a BRIN index cou= ld be > used for (bulk) FK validation. > = > So I would like to be able to see the *plan* for the query. > I was able to show the plan and see that BRIN can be used like so: > |SET auto_explain.log_nested_statements=3Don; SET client_min_messages=3D= debug; SET auto_explain.log_min_duration=3D0; > Should the plan be visible in explain (not auto-explain) ? For development purposes, I thin I could get the plan this way: SET debug_print_plan TO on; SET client_min_messages TO debug; (The plan is cached, so I think the query will only be displayed during th= e first execution in the session). Do you think that the documentation should advise the user to create BRIN index on the FK table? > BTW did you see this older thread ? > https://www.postgresql.org/message-id/flat/CA%2BU5nMLM1DaHBC6JXtUMfcG6f7= FgV5mPSpufO7GRnbFKkF2f7g%40mail.gmail.com Not yet. Thanks. [1] https://www.postgresql.org/message-id/20200630011729.mr25bmmbvsattxe2%= 40alap3.anarazel.de -- = Antonin Houska Web: https://www.cybertec-postgresql.com