Re: missing estimation for coalesce function - Mailing list pgsql-hackers

From Laurenz Albe
Subject Re: missing estimation for coalesce function
Date
Msg-id 3524f9466c1a03e35bc0a78d9f72eaba572c0462.camel@cybertec.at
Whole thread Raw
In response to missing estimation for coalesce function  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: missing estimation for coalesce function  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
On Wed, 2019-11-27 at 08:47 +0100, Pavel Stehule wrote:
> The most significant issue was missing correct estimation for coalesce function.
> He had to rewrite coalesce(var, X) = X to "var IS NULL or var = X".
> Then the result was very satisfactory.
> 
> postgres=# explain analyze select * from xxx where coalesce(a, 0) = 0;
>                                              QUERY PLAN                                             
> ----------------------------------------------------------------------------------------------------
>  Seq Scan on xxx  (cost=0.00..194.00 rows=60 width=4) (actual time=0.041..4.276 rows=11000 loops=1)

I think that this is asking for a planner support function:
https://www.postgresql.org/docs/current/xfunc-optimization.html

Yours,
Laurenz Albe




pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: FETCH FIRST clause WITH TIES option
Next
From: Andy Fan
Date:
Subject: Re: Planner chose a much slower plan in hashjoin, using a large tableas the inner table.