Thread

  1. Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*)

    Matheus Alcantara <matheusssilv97@gmail.com> — 2025-11-03T20:38:35Z

    Hi, thanks for working on this!
    
    On Thu Oct 30, 2025 at 1:20 AM -03, David Rowley wrote:
    > 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.
    >
    I looked the code and it seems to be in a good shape, but I tried to
    apply the v2 on top of e7ccb247b38 in master to run some tests and a
    rebase is necessary.
    
    git am v2-0001-Have-the-planner-replace-COUNT-ANY-with-COUNT-whe.patch
    Applying: Have the planner replace COUNT(ANY) with COUNT(*), when possible
    error: patch failed: contrib/postgres_fdw/expected/postgres_fdw.out:2975
    error: contrib/postgres_fdw/expected/postgres_fdw.out: patch does not apply
    error: patch failed: src/test/regress/expected/aggregates.out:1219
    error: src/test/regress/expected/aggregates.out: patch does not apply
    Patch failed at 0001 Have the planner replace COUNT(ANY) with COUNT(*), when possible
    
    --
    Matheus Alcantara