Re: Performance degradation of REFRESH MATERIALIZED VIEW

From: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>, Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Paul Guo <guopa(at)vmware(dot)com>
Subject: Re: Performance degradation of REFRESH MATERIALIZED VIEW
Date: 2021-05-21 18:10:13
Message-ID: 3c6e1b84-0547-ee55-8800-1dd8227b09b6@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 5/21/21 6:43 PM, Andres Freund wrote:
> Hi,
>
> ...
>
>> Attached are the flame graphs for all three cases. The change in master is
>> pretty clearly visible, but I don't see any clear difference between old and
>> patched code :-(
>
> I'm pretty sure it's the additional WAL records?
>

Not sure. If I understand what you suggested elsewhere in the thread, it
should be fine to modify heap_insert to pass the page recptr to
visibilitymap_set, roughly per the attached patch.

I'm not sure it's correct, but it does eliminate the Heap2/VISIBILITY
records for me (when applied on top of your patch). Funnily enough it
does make it a wee bit slower:

patch #1: 56941.505
patch #2: 58099.788

I wonder if this might be due to -fno-omit-frame-pointer, though, as
without it I get these timings:

0c7d3bb99: 25540.417
master: 31868.236
patch #1: 26566.199
patch #2: 26487.943

So without the frame pointers there's no slowdown, but there's no clear
improvement after removal of the WAL records either :-(

regards

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment Content-Type Size
pin2.patch text/x-patch 1.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2021-05-21 18:19:13 Re: compute_query_id and pg_stat_statements
Previous Message Robert Haas 2021-05-21 16:52:54 Re: Race condition in recovery?