Re: 14.1 immutable function, bad performance if check number = 'NaN' - Mailing list pgsql-bugs

From Merlin Moncure
Subject Re: 14.1 immutable function, bad performance if check number = 'NaN'
Date
Msg-id CAHyXU0ye7LvS0W+MOvV40TVMaw5fF0OrogF2TGq4jHBHvVo+LA@mail.gmail.com
Whole thread Raw
In response to 14.1 immutable function, bad performance if check number = 'NaN'  (Federico Travaglini <federico.travaglini@aubay.it>)
Responses R: 14.1 immutable function, bad performance if check number = 'NaN'  (Federico Travaglini <federico.travaglini@collaboration.aubay.it>)
List pgsql-bugs
On Mon, Apr 25, 2022 at 11:58 AM Federico Travaglini <federico.travaglini@aubay.it> wrote:

Good evening, and thanks to your excellent Postgres.

 

This funcion in used as a column in a select on about 400k records

If I leave the highlighted row it takes 27 seconds, otherwise 14 seconds! Such behaviour looks not to be reasonable.


lightly testing this, I got 10million iterations in about two seconds, about the same after commenting the NaN test.  Given that, problem is probably failure to inline query.  Careful examination of explain of wrapping query should prove that.

merlin

pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: 14.1 immutable function, bad performance if check number = 'NaN'
Next
From: PG Bug reporting form
Date:
Subject: BUG #17468: Ranking of search results: ts_rank_cd with normalization variant 4