Re: Rethinking plpgsql's assignment implementation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Chapman Flack <chap(at)anastigmatix(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Rethinking plpgsql's assignment implementation
Date: 2020-12-14 16:25:16
Message-ID: 911973.1607963116@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> I checked a performance and it looks so access to record's field is faster,
> but an access to arrays field is significantly slower

Hmm, I'd drawn the opposite conclusion in my own testing ...

> for i in 1..5000
> loop
> if a[i] > a[i+1] then
> aux := a[i];
> a[i] := a[i+1]; a[i+1] := aux;
> rep := true;
> end if;
> end loop;

... but I now see that I'd not checked cases like "a[i] := a[j]".
exec_check_rw_parameter() is being too conservative about whether
it can optimize a case like that. The attached incremental patch
fixes it.

> I tested pi calculation
> ...
> And the performance is 10% slower than on master

Can't reproduce that here. For the record, I get the following
timings (medians of three runs) for your test cases:

HEAD:

sort: Time: 13974.709 ms (00:13.975)
pi_est_1(10000000): Time: 3537.482 ms (00:03.537)
pi_est_2(10000000): Time: 3546.557 ms (00:03.547)

Patch v1:

sort: Time: 47053.892 ms (00:47.054)
pi_est_1(10000000): Time: 3456.078 ms (00:03.456)
pi_est_2(10000000): Time: 3451.347 ms (00:03.451)

+ exec_check_rw_parameter fix:

sort: Time: 12199.724 ms (00:12.200)
pi_est_1(10000000): Time: 3357.955 ms (00:03.358)
pi_est_2(10000000): Time: 3367.526 ms (00:03.368)

I'm inclined to think that the differences in the pi calculation
timings are mostly chance effects; there's certainly no reason
why exec_check_rw_parameter should affect that test case at all.

regards, tom lane

Attachment Content-Type Size
v1-0007-performance-fix.patch text/x-diff 1.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhihong Yu 2020-12-14 16:26:29 Re: Parallel Inserts in CREATE TABLE AS
Previous Message Bharath Rupireddy 2020-12-14 16:17:58 Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit