Re: Performance degradation of REFRESH MATERIALIZED VIEW
Tomas Vondra <tomas.vondra@enterprisedb.com>
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, Andres Freund
<andres@anarazel.de>,
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>,
Kyotaro Horiguchi <horikyota.ntt@gmail.com>,
PostgreSQL-development <pgsql-hackers@postgresql.org>,
Pavan Deolasee <pavan.deolasee@gmail.com>,
Anastasia Lubennikova <a.lubennikova@postgrespro.ru>,
Jeff Janes <jeff.janes@gmail.com>, Paul Guo <guopa@vmware.com>
Date: 2021-05-18T18:34:08Z
Lists: pgsql-hackers
On 5/18/21 4:20 AM, Masahiko Sawada wrote: > ... >>>> >>>>> I think the changes for heap_multi_insert() are fine so we can revert >>>>> only heap_insert() part if we revert something from the v14 tree, >>>>> although we will end up not inserting frozen tuples into toast tables. >>>>> >>>> >>>> I'd be somewhat unhappy about reverting just this bit, because it'd mean >>>> that we freeze rows in the main table but not rows in the TOAST tables >>>> (that was kinda why we concluded we need the heap_insert part too). >>>> >>>> I'm still a bit puzzled where does the extra overhead (in cases when >>>> freeze is not requested) come from, TBH. >>> >>> Which cases do you mean? Doesn't matview refresh always request to >>> freeze tuples even after applying the patch proposed on this thread? >>> >> >> Oh, I didn't realize that! That'd make this much less of an issue, I'd >> say, because if we're intentionally freezing the rows it's reasonable to >> pay a bit of time (in exchange for not having to do it later). The >> original +25% was a bit too much, of course, but +5% seems reasonable. > > Yes. It depends on how much the matview refresh gets slower but I > think the problem here is that users always are forced to pay the cost > for freezing tuple during refreshing the matview. There is no way to > disable it unlike FREEZE option of COPY command. > Yeah, I see your point. I agree it's unfortunate there's no way to disable freezing during REFRESH MV. For most users that trade-off is probably fine, but for some cases (matviews refreshed often, or cases where it's fine to pay more but later) it may be an issue. From this POV, however, it may not be enough to optimize the current freezing code - it's always going to be a bit slower than before. So the only *real* solution may be adding a FREEZE option to the REFRESH MATERIALIZED VIEW command. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Commits
-
Fix pg_visibility regression failure with CLOBBER_CACHE_ALWAYS
- d1f0aa769691 14.0 landed
-
Revert most of 39b66a91bd
- 8e03eb92e9ad 14.0 landed
-
Fix COPY FREEZE with CLOBBER_CACHE_ALWAYS
- 39b66a91bdeb 14.0 cited