Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*) - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*)
Date
Msg-id CADkLM=eiqMZQmumN8T7Adp_ARN=0e00cX7y3f85wChrPrxOKBw@mail.gmail.com
Whole thread Raw
In response to Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*)  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-hackers
which might be a more realistic thing if the query without the WHERE
clause was part of a VIEW. However, we don't currently have any
infrastructure to detect when a column *is* NULL. There's only the
opposite with expr_is_nonnullable() or var_is_nonnullable().

But we'd still catch NULL constants, yes?
 
I've attached a very slightly revised version of the patch. I became
aware of a function named get_func_support(), which can be used rather
than fetching the pg_proc tuple from SysCache, which I was doing in
v1.  No other changes.

David

 The change is a big win for clarity. Applies clean. Passes.

pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: [PATCH] Add pg_get_type_ddl() to retrieve the CREATE TYPE statement
Next
From: David Rowley
Date:
Subject: Re: another autovacuum scheduling thread