For loop execution times in PostgreSQL 12 vs 15

From: Adithya Kumaranchath <akumaranchath(at)live(dot)com>
To: "pgsql-performance(at)lists(dot)postgresql(dot)org" <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: For loop execution times in PostgreSQL 12 vs 15
Date: 2023-02-10 18:53:09
Message-ID: HE1P193MB0107A3613E26425919BE0B9CDBDE9@HE1P193MB0107.EURP193.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi all,

I am running a simple test and am curious to know why a difference in execution times between PostgreSQL 12 vs PostgreSQL 15.

I have this function:
CREATE function test() returns int language plpgsql as $$
declare
v_number bigint;
v_multiplier float = 3.14159;
loop_cnt bigint;
begin

for loop_cnt in 1..1000000000
loop
v_number := 1000;
v_number := v_number * v_multiplier;
end loop;

return 0;

end;$$;

I execute this in PostgreSQL 12:

[cid:f1c8e1b4-c488-457b-93fb-31617a54a567]

PostgreSQL 15:
[cid:3db591b7-7913-4705-be81-10a5d4c8989f]

It is much faster in 15 than in 12, and while I love the performance improvement. I am curious to know the rationale behind this improvement on PostgreSQL 15.

The test result is from PostgreSQL on Windows but I observed the same behavior on Linux OS too.

Server Spec:
Intel i7-8650U CPU @1.90GHz 2.11GHz
RAM 16 GB
Windows 11 Enterprise

Thanks,
Adi

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Pavel Stehule 2023-02-10 19:35:11 Re: For loop execution times in PostgreSQL 12 vs 15
Previous Message Mark Hills 2023-02-10 10:49:25 Re: Domain check taking place unnecessarily?