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 1kbBQO-0005cb-Ib for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Nov 2020 23:45:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kbBQN-0004Rj-Ev for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Nov 2020 23:45:43 +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 1kbBQN-0004RU-4G for pgsql-hackers@lists.postgresql.org; Fri, 06 Nov 2020 23:45:43 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kbBQK-0001hH-1U for pgsql-hackers@postgresql.org; Fri, 06 Nov 2020 23:45:41 +0000 Received: by mail-ed1-x544.google.com with SMTP id p93so2949548edd.7 for ; Fri, 06 Nov 2020 15:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WzBxoPsgfFsqjXDrI8JprwZ05SouH3Zvi+mkVWV6diA=; b=LxfGOaI+Iiq9a4yQcv+ET9e2fdieInYsK/e8KDoyUP9HKu3JIdAr6T6Dr7m/id47GJ D2u+ebPxBGbSJgxj4BcSTs+k6yhUpfXJ3qUkjWG/63LZJ6rFMi5gyBig/zKGbVEOKEGB KlXLEgyxXmfOtWE+WKCfqnxUjLuKIFhNbcaz2jNGC+uGQ+1nimkbL4UviEgY9tfKDaMb wNQ9lXSONH0+cPl8OfHlWZfknsPAKIgFLr5Oxy2FaSqGH4gqHfGcD2DJ+w2A3mUshZzE wGhf3crmsK+4J5kTE6QQ+bXdAYtSsw50VRrrfiEjznAKM/WFmSnBitRnqeKDxzn45Z0X JUrw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=WzBxoPsgfFsqjXDrI8JprwZ05SouH3Zvi+mkVWV6diA=; b=Ahz63yMfQOb3KU2hPMM5oDpwx9sNrRHTbx4eFzCn+fqMu+WvJGNa9eIQsDRg5+/gtH ANt1dgbxLgZVJ8lbw9V51CrR5LF0VCZZKGnhI2FjwKaTN78RjCSAPW6nXFp6yp67kz1/ 5G0fPzEcE59aTnQzfb63hOwD+1484VIx601Pswcepj4O20++QT6VlJ+9WKatJwjuHiFi a2/R3XG7tmaDKugOxJFOR3NGfeD5nskaKqnweDss9RCtTdvQRRXXlEsp22g0NRo2TWYw c2iDQxc9f3ZmkPdIzr/Q4TdE0JOawyMunrdWDlMqj52ebHhUosC4v+0cuSJQ+hlAF+YK hk9w== X-Gm-Message-State: AOAM530kORkiBebUlXTaxoolbEvSGr+WYuo8QRMMQnsFbUxf7qUtrgHH JJXSgQH4/sa3X5Ldzg95CcQDx6h4vbfC7iRjYf5CxRbTR6Q0p9IBHQIrIB9RF+xnaBMVteiXR7V FCamGI5gsbpscmklaCt+nknWH+57/flU039vp4zyeM7aEUQg8x6aeAlceUee0nudnkayDc6xwyB 7LrfXmzl9lseeRfeR4EFtVOtYwSkfwkLWeXjnV X-Google-Smtp-Source: ABdhPJxQWj2r0esMazc+ZIyF5WY0tqD8UFbeBjQmjYFiKpg4DMyRZ72p3dG+QIWIcVQjEz1Vd12IYg== X-Received: by 2002:aa7:d4c9:: with SMTP id t9mr3739464edr.313.1604706336724; Fri, 06 Nov 2020 15:45:36 -0800 (PST) Received: from localhost (ip-86-49-245-76.net.upcbroadband.cz. [86.49.245.76]) by smtp.gmail.com with ESMTPSA id y12sm2055923ede.82.2020.11.06.15.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 15:45:36 -0800 (PST) Date: Sat, 7 Nov 2020 00:45:29 +0100 From: Tomas Vondra To: Alvaro Herrera Cc: Tomas Vondra , pgsql-hackers@postgresql.org Subject: Re: Fix brin_form_tuple to properly detoast data Message-ID: <20201107004529.1b16417d@enterprisedb.com> In-Reply-To: <20201105211604.GA3054@alvherre.pgsql> References: <21cacd39-1ca2-54ef-4f3e-ac493238832c@enterprisedb.com> <20201105211604.GA3054@alvherre.pgsql> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, 5 Nov 2020 18:16:04 -0300 Alvaro Herrera wrote: > On 2020-Nov-05, Tomas Vondra wrote: > > > On 11/5/20 6:17 PM, Alvaro Herrera wrote: > > > > There are recent changes in vacuum for temp tables (commit > > > 94bc27b57680?) that would maybe make this stable enough, without > > > having to have the CIC there. At least, I tried it locally a few > > > times and it appears to work well. This won't work for older > > > releases though, just master. This is patch 0001 attached here. > > > > IIUC you're suggesting to use a temporary table in the test? > > Unfortunately, this does not work on older releases, and IMHO the > > test should be backpatched too. IMHO the CIC "hack" is acceptable, > > unless there's a better solution that I'm not aware of. > > Oh, sure, the CIC hack is acceptable for the older branches. I'm just > saying that you can use a temp table everywhere, and keep CIC in the > old branches and no CIC in master. > > > This got me thinking though - wouldn't it be better to handle too > > large values by treating the range as "degenerate" (i.e. store NULL > > and consider it as matching all queries), instead of failing the > > CREATE INDEX or DML? I find the current behavior rather annoying, > > because it depends on the other rows in the page range, not just on > > the one row the user deals with. Perhaps this might even be > > considered an information leak about the other data. Of course, not > > something this patch should deal with. > > Hmm. Regarding text I remember thinking we could just truncate values > (as we do for LIKE, as I recall). I suppose that strategy would work > even for bytea. > > > > > > +/* > > > > + * This enables de-toasting of index entries. Needed until > > > > VACUUM is > > > > + * smart enough to rebuild indexes from scratch. > > > > + */ > > > > > > ... because, surely, we're now never working on having VACUUM > > > rebuild indexes from scratch. In fact, I wonder if we need the > > > #define at all. I propose to remove all those #ifdef lines in > > > your patch. > > > > That's a verbatim copy of a comment from indextuple.c. IMHO we > > should keep it the same in both places. > > Sure, if you want to. > > > > The fix looks good to me. I just added a comment in 0003. > > > > Thanks. Any opinions on fixing this in existing clusters? Any > > better ideas than just giving users the SQL query to list > > possibly-affected indexes? > > None here. > OK, pushed and backpatched all the way back to 9.5. I decided not to use the temporary table - I'd still need to use the CIC trick on older releases, and there were enough differences already. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company