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 1nbgK7-00016i-Lb for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Apr 2022 10:22:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbgK6-0004fP-4U for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Apr 2022 10:22:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbgK5-0004fG-RU for pgsql-hackers@lists.postgresql.org; Tue, 05 Apr 2022 10:22:05 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nbgK2-0007Dg-Gi for pgsql-hackers@lists.postgresql.org; Tue, 05 Apr 2022 10:22:04 +0000 Received: by mail-ej1-x632.google.com with SMTP id bq8so25654443ejb.10 for ; Tue, 05 Apr 2022 03:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=from:to:subject:in-reply-to:references:comments:mime-version :content-id:content-transfer-encoding:date:message-id; bh=qsUB9q2NO+0tVc/le585g79+bOwvFOslg8BGXlAVST0=; b=366MnWI9s92vdzliaoF8YyqEPYmOrbXNTjPvz2dKLS32Vgn0f+Dw2N80OA7YcCBVbA T3MZD/pDvcJL2odXQP54l5sXQy2yuVdSt3KBmRChudPt4lP/OrC0/ObkRa44QVUrhYiA 4tD29Nhud5xBQTbgbR461I0unV54EQxdDdjnJXHHBeu4nCVkLDpitjOv4WHNXGQxrhDw z5AkPyOmuPZyPI0GgELErqPfzUBzfVZ6y8KFeZhEZBhxt4VDMJeykWzgS1v2lC13wug5 edw9Hg0ofEajbrbXXxOhfI263DG54wbA5nk1bWi/aOsnsDH3toLHX6DIK7+y7SoloGvi GNWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references:comments :mime-version:content-id:content-transfer-encoding:date:message-id; bh=qsUB9q2NO+0tVc/le585g79+bOwvFOslg8BGXlAVST0=; b=KxHlhWpMzhsbQTePjVnI8fMSqRzETVYSiNe2tFJdjB5hWtRGw5+hwuhRmV1SeR6UIi xL8YSoqfSUL2CqyFdA4661Zo308GacpzYdlOhCngZ8w1MWPzOWGopBh8DgDcnKGSASeH ib5cw8Fuwja57/EqsmkZlhvQoDiMuAiTfeF609nVmxqbV9I3rOHNuCsmBNm0c0vgIdDA jPRiDi+zKE1b9CgcEcCTXS79eb1TnPmuxhr7Ti9+N4C3gi/OQEgwrTVXHe/O1WChwV5r 3yKVjDCPo9E8p2TgGSKmLOcjncN9JvnRY7teQWwQpp+BnHePhwmM7F2w7uJFF/CVVLh9 5u1Q== X-Gm-Message-State: AOAM533NXvXna3RmVI8sQK8Q96xLw+pXkq3vwJTh4A5K/Hg36DIndsM/ Z2u2br7mRPJ4/nQJZG/CFU8OtT1csHvC3A== X-Google-Smtp-Source: ABdhPJzzTzhLCNi8P7S9jh+O3WjtsbloWYyk/e9I3XJUUY85QLl//GNHHNuz0WWeA64S6sEVOJ2pow== X-Received: by 2002:a17:907:e8d:b0:6e0:19e7:9549 with SMTP id ho13-20020a1709070e8d00b006e019e79549mr2870667ejc.44.1649154120728; Tue, 05 Apr 2022 03:22:00 -0700 (PDT) Received: from antos (85-207-121-76.static.bluetone.cz. [85.207.121.76]) by smtp.gmail.com with ESMTPSA id et21-20020a170907295500b006e7f1abe2ccsm2236791ejc.75.2022.04.05.03.22.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 03:22:00 -0700 (PDT) From: Antonin Houska To: pgsql-hackers@lists.postgresql.org Subject: Re: Logical replication row filtering and TOAST In-reply-to: <84638.1649152255@antos> References: <84638.1649152255@antos> Comments: In-reply-to Antonin Houska message dated "Tue, 05 Apr 2022 11:50:55 +0200." X-Mailer: MH-E 8.6+git; nmh 1.7+dev; GNU Emacs 27.2.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <85261.1649154136.1@antos> Content-Transfer-Encoding: quoted-printable Date: Tue, 05 Apr 2022 12:22:16 +0200 Message-ID: <85262.1649154136@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Antonin Houska wrote: > I spent some time thinking about a special case of evaluation of the row > filter and wrote a comment that might be useful (see the attachment). Ho= wever > now I think that it's not perfect if the code really relies on the fact = that > value of an indexed column cannot be TOASTed due to size restrictions. > = > I could hit two different error messages when trying activate TOAST on a= n > index column (in this case PG was build with 16kB pages), but still I th= ink > the code is unnecessarily fragile if it relies on such errors: > = > = > ERROR: index row requires 8224 bytes, maximum size is 8191 > = > ERROR: index row size 8048 exceeds btree version 4 maximum 5432 for ind= ex "b_pkey" > DETAIL: Index row references tuple (0,3) in relation "b". > HINT: Values larger than 1/3 of a buffer page cannot be indexed. > = > = > Note that at least in ExtractReplicaIdentity() we do expect that an inde= xed > column value can be TOASTed. > = > /* > * If the tuple, which by here only contains indexed columns, still has > * toasted columns, force them to be inlined. This is somewhat unlikely > * since there's limits on the size of indexed columns, so we don't > * duplicate toast_flatten_tuple()s functionality in the above loop ove= r > * the indexed columns, even if it would be more efficient. > */ > if (HeapTupleHasExternal(key_tuple)) > { > HeapTuple oldtup =3D key_tuple; > = > key_tuple =3D toast_flatten_tuple(oldtup, desc); > heap_freetuple(oldtup); > } > = > Do I miss anything? Well, I see now that the point might be that, in heap_update(), "id_has_external" would be true the indexed value could be TOASTed, so tha= t the (flattened) old tuple would be WAL logged: old_key_tuple =3D ExtractReplicaIdentity(relation, &oldtup, bms_overlap(modified_attrs, id_attrs) || id_has_external, &old_key_copied); Nevertheless, a comment in pgoutput_row_filter(), saying that TOASTed valu= es are not expected if old_slot is NULL, might be useful. -- = Antonin Houska Web: https://www.cybertec-postgresql.com