Re: EXPLAIN/EXPLAIN ANALYZE REFRESH MATERIALIZED VIEW

From: japin <japinli(at)hotmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: EXPLAIN/EXPLAIN ANALYZE REFRESH MATERIALIZED VIEW
Date: 2021-01-08 16:20:28
Message-ID: MEYP282MB16698107786A45784694D989B6AE0@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Fri, 08 Jan 2021 at 17:24, Bharath Rupireddy wrote:
> On Fri, Jan 8, 2021 at 1:50 PM japin <japinli(at)hotmail(dot)com> wrote:
>> Thanks for updating the patch!
>>
>> + /* Get the data generating query. */
>> + dataQuery = get_matview_query(stmt, &matviewRel, &matviewOid);
>>
>> - /*
>> - * Check for active uses of the relation in the current transaction, such
>> - * as open scans.
>> - *
>> - * NB: We count on this to protect us against problems with refreshing the
>> - * data using TABLE_INSERT_FROZEN.
>> - */
>> - CheckTableNotInUse(matviewRel, "REFRESH MATERIALIZED VIEW");
>> + relowner = matviewRel->rd_rel->relowner;
>>
>> After apply the patch, there is a duplicate
>>
>> relowner = matviewRel->rd_rel->relowner;
>
> Corrected that.
>
>> + else if(matviewInfo)
>> + dest = CreateTransientRelDestReceiver(matviewInfo->OIDNewHeap);
>>
>> If the `matviewInfo->OIDNewHeap` is invalid, IMO we don't need create
>> DestReceiver, isn't it? And we should add a space after `if`.
>
> Yes, we can skip creating the dest receiver when OIDNewHeap is
> invalid, this can happen for plain explain refresh mat view case.
>
> if (explainInfo && !explainInfo->es->analyze)
> OIDNewHeap = InvalidOid;
> else
> OIDNewHeap = get_new_heap_oid(stmt, matviewRel, matviewOid,
> &relpersistence);
>
> Since we don't call ExecutorRun for plain explain, we can skip the
> dest receiver creation. I modified the code as below in explain.c.
>
> if (into)
> dest = CreateIntoRelDestReceiver(into);
> else if (matviewInfo && OidIsValid(matviewInfo->OIDNewHeap))
> dest = CreateTransientRelDestReceiver(matviewInfo->OIDNewHeap);
> else
> dest = None_Receiver;
>
> Thanks for taking a look at the patches.
>

Thanks!

> Attaching v3 patches, please consider these for further review.
>

I find that both the declaration and definition of match_matview_with_new_data()
have a tab between type and variable. We can use pgindent to fix it.
What do you think?

static void
match_matview_with_new_data(RefreshMatViewStmt *stmt, Relation matviewRel,
^
Oid matviewOid, Oid OIDNewHeap, Oid relowner,
int save_sec_context, char relpersistence,
uint64 processed)
^

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ryan Lambert 2021-01-08 16:50:03 Re: WIP: System Versioned Temporal Table
Previous Message Bruce Momjian 2021-01-08 16:16:17 Re: data_checksums enabled by default (was: Move --data-checksums to common options in initdb --help)