From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
Cc: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Joseph Koshakow <koshy44(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Infinite Interval |
Date: | 2023-09-16 00:00:00 |
Message-ID: | CACJufxFvOuMB3tfEnStSMPLnN16+ZZcYZaSFhio6qaRcgqqi6g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
hi.
fixed the doc special value inf/-inf reference. didn't fix the EXTRACT
function doc issue.
I refactor the avg(interval), sum(interval), so moving aggregate,
plain aggregate both work with +inf/-inf.
no performance degradation, in fact, some performance gains.
--setup for test performance.
create unlogged table interval_aggtest AS
select g::int as a
,make_interval(years => g % 100, days => g % 100, hours => g %
200 , secs => random()::numeric(3,2) *100 ) as b
from generate_series(1, 100_000) g;
--use foreign data wrapper to copy exact content to interval_aggtest_no_patch
create unlogged table interval_aggtest_no_patch AS
select * from interval_aggtest;
--queryA
explain (analyze, costs off, buffers)
SELECT a, avg(b) OVER(ROWS BETWEEN 1 preceding AND 2 FOLLOWING)
from interval_aggtest \watch i=0.1 c=10
--queryB
explain (analyze, costs off, buffers)
SELECT a, avg(b) OVER(ROWS BETWEEN 1 preceding AND 2 FOLLOWING)
from interval_aggtest_no_patch \watch i=0.1 c=10
--queryC
explain (analyze, costs off, buffers)
SELECT a, sum(b) OVER(ROWS BETWEEN 1 preceding AND 2 FOLLOWING)
from interval_aggtest \watch i=0.1 c=10
--queryD
explain (analyze, costs off, buffers)
SELECT a, sum(b) OVER(ROWS BETWEEN 1 preceding AND 2 FOLLOWING)
from interval_aggtest_no_patch \watch i=0.1 c=10
--queryE
explain (analyze, costs off, buffers)
SELECT sum(b), avg(b)
from interval_aggtest \watch i=0.1 c=10
--queryF
explain (analyze, costs off, buffers)
SELECT sum(b), avg(b)
from interval_aggtest_no_patch \watch i=0.1 c=10
queryA execute 10 time, last executed time(ms) 748.258
queryB execute 10 time, last executed time(ms) 1059.750
queryC execute 10 time, last executed time(ms) 697.887
queryD execute 10 time, last executed time(ms) 708.462
queryE execute 10 time, last executed time(ms) 156.237
queryF execute 10 time, last executed time(ms) 405.451
---------------------------------------------------------------------
The result seems right, I am not %100 sure the code it's correct.
That's the best I can think of. You can work based on that.
Attachment | Content-Type | Size |
---|---|---|
v20-0005-doc-for-special-interval-value.patch | text/x-patch | 1.3 KB |
v20-0004-Revert-Remove-dead-code-in-DecodeInterval.patch | text/x-patch | 1021 bytes |
v20-0002-Check-for-overflow-in-make_interval.patch | text/x-patch | 5.0 KB |
v20-0003-Add-infinite-interval-values.patch | text/x-patch | 96.9 KB |
v20-0001-Move-integer-helper-function-to-int.h.patch | text/x-patch | 3.3 KB |
v20-0006-refactor-avg-interval-sum-interval-aggregate.patch | text/x-patch | 25.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2023-09-16 00:00:11 | Re: Performance degradation on concurrent COPY into a single relation in PG16. |
Previous Message | Yurii Rashkovskii | 2023-09-15 21:36:16 | Re: SET ROLE documentation improvement |