Re: 'infinity'::Interval should be added

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, isaac(dot)morland(at)gmail(dot)com, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: 'infinity'::Interval should be added
Date: 2018-12-15 19:43:49
Message-ID: 25818.1544903029@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)de> writes:
> On 2018-12-15 09:44:50 -0500, Tom Lane wrote:
>> Yes. The performance argument has some merit for cases like int4 and
>> float8, where the "useful work" might be as small as one machine
>> instruction. But timestamp and interval operations are, for the most
>> part, pretty darn expensive. I doubt that adding special cases to
>> them for infinity is going to move the needle noticeably. (And as
>> for JIT, I sincerely hope that the compiler is not dumb enough to try
>> to in-line those functions.)

> Something like interval_pl is cheap enough to inline (without inlinining
> palloc, and elog.c infrastructure), even though there's repeated
> ereports() checks with different parameters / line numbers [1]. Boils
> down to ~70 instructions, which allows inlining. But I suspect more
> important than those, are operations like timestamp_lt etc, which
> currently are ~8 instructions. It's pretty common to have a
> timestamp_lt or such in sequential scans, so that's good too.

I said "for the most part", I did not say that every single function
on those types is expensive.

Note that timestamp_lt etc don't actually need any special case for
infinity, and we could hope that the infinity representation for interval
makes it possible to likewise not special-case it in interval comparisons.
But I think it's silly to argue that infinity handling is a significant
fraction of something like timestamp_pl_interval or timestamp_part.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-12-15 19:44:30 Re: Variable-length FunctionCallInfoData
Previous Message Andres Freund 2018-12-15 19:37:00 Re: Pluggable Storage - Andres's take