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 1hnXFC-0003Hu-5x for pgsql-bugs@arkaria.postgresql.org; Tue, 16 Jul 2019 23:52:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hnXFB-00085o-1r for pgsql-bugs@arkaria.postgresql.org; Tue, 16 Jul 2019 23:52:25 +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 1hnXFA-00085h-Qm for pgsql-bugs@lists.postgresql.org; Tue, 16 Jul 2019 23:52:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnXF8-0001xZ-6j for pgsql-bugs@lists.postgresql.org; Tue, 16 Jul 2019 23:52:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x6GNqJde023316; Tue, 16 Jul 2019 19:52:19 -0400 From: Tom Lane To: Manuel Rigger cc: PostgreSQL mailing lists Subject: Re: BETWEEN SYMMETRIC condition results in "row is too big: ..., maximum size 8160" In-reply-to: References: Comments: In-reply-to Manuel Rigger message dated "Wed, 17 Jul 2019 01:29:18 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23314.1563321139.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 16 Jul 2019 19:52:19 -0400 Message-ID: <23315.1563321139@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Manuel Rigger writes: > I noticed that indexes that use nested BETWEEN SYMMETRIC operators > quickly exceed some limit, which is indicated by errors such as > "ERROR: row is too big: size 8440, maximum size 8160". For example, > consider the following (contrived) index: > CREATE TABLE t0(c0 TEXT); > CREATE INDEX i0 ON t0(c0) WHERE ((FALSE BETWEEN SYMMETRIC TRUE AND > (t0.c0 || t0.c0 IN (t0.c0, t0.c0, '1', t0.c0 || t0.c0, t0.c0 || t0.c0 > || t0.c0))) BETWEEN SYMMETRIC TRUE AND TRUE) BETWEEN SYMMETRIC TRUE > AND TRUE; -- ERROR: row is too big: size 8440, maximum size 8160 It's not specifically BETWEEN SYMMETRIC that's at issue --- any sufficiently complex index WHERE condition or index expression will do it. (BETWEEN SYMMETRIC helps things along because it duplicates its subexpressions, though.) > Is this an expected limitation? Yeah. Those expressions are stored in pg_index, which doesn't have a TOAST table so there's a hard limit on its row width. Adding a TOAST table would create some interesting circularity issues, and there doesn't seem to be that much real-world use for very complex index expressions or predicates, so we haven't tried to fix it. (If you're desperate for some way to overcome the limit, though, you can do so by creating a SQL function and using it in the index expression.) If you're interested, there was some discussion not too long ago about which system catalogs should have TOAST tables: https://www.postgresql.org/message-id/flat/84ddff04-f122-784b-b6c5-3536804= 495f8%40joeconway.com regards, tom lane