Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nVJgN-0008Tt-6a for pgsql-docs@arkaria.postgresql.org; Fri, 18 Mar 2022 20:58:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nVJgL-0004UR-Np for pgsql-docs@arkaria.postgresql.org; Fri, 18 Mar 2022 20:58:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nVJgL-0004UH-Dv for pgsql-docs@lists.postgresql.org; Fri, 18 Mar 2022 20:58:45 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nVJgJ-0000Qq-0E for pgsql-docs@postgresql.org; Fri, 18 Mar 2022 20:58:45 +0000 Received: by mail-ed1-x536.google.com with SMTP id g20so11618561edw.6 for ; Fri, 18 Mar 2022 13:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=M0dPzZZV9BytjWyRECD4nHK9a7aKTJzTpT8VdEY0Gmk=; b=h2lz3euIgK/dsEqv6zgvcOnaCMkhGgHzgIlWl3RqbU4WvlwG+/UhB8GVVd35GaXz80 6L51clKwjbpflkgWwcEqbzU4/xpDeBZ0dYjyOvmtYr2aWrXiquFOwFUQA/b4WSoeMDpy WHnMdxrxSrZVL+VFzGIzOH0039CZ1DH2IWBv36j27CL0HeuT7d9pXsTQO3/JwhlDhvUx 2kzyB00viRU+nbgxA8ZG9nAguH6lG/YnupKwyXMf3Zw7unvEn1qillsfaiNJuLZJ6B8y hB0f6Th+h/VkAFR96e7vlfraTs+YFzFt1KADkYbIJg/xylrynbd9lbDHOT9/ufVaymek 4Zvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=M0dPzZZV9BytjWyRECD4nHK9a7aKTJzTpT8VdEY0Gmk=; b=8DDxwYB/mEUDJnAeuqq0ZDShupzZNN3RPNRmzhEXC3mtg2Wa/W+WmMbmUUm79gC03C b3HUTaKqzIDOx6u1DCrPa2GasT3Hh302KQZ2R/IzUX4yGtb5CRF0W1D2wmgWufYJ0N8g h+vFCPQhjCFyqhm7THfbAVBuVteeX/s5ORomXWZqi/Pv0TVLAlrgqLk0j7ld+/ct4QpG f3jvA2lb1qXxqF2jlYimd/3wX3Ymv6W0Dw5zyGMSXwQ7WdkhsJFbXNGLHRTJcs630M4K 7ckBOzAK5yLgcPW+3g1ynEWNOuzxXcbO3UF6zz/qIdl8G+X1B0vFq+oTTEc4P2DQXNcy 9i0w== X-Gm-Message-State: AOAM533WkXT/9GZIJKy10MGgmLoVWIz8JfqB+Tfoiwy5HasRGjGrkGBL ivpd8jL7NqZ/q10FtrOLyV92I3UKezEdyQB5A41UmYiOKc8= X-Google-Smtp-Source: ABdhPJyiXYXM4Vsf3eJMgpQdXdo9svKB7XmZmQZBLBUBl56cgdeUgj0HjW8zvH2AkYH0Poj1+VttGVudosLXVLWC7aE= X-Received: by 2002:a50:d84c:0:b0:418:f176:79df with SMTP id v12-20020a50d84c000000b00418f17679dfmr11106601edj.353.1647637121822; Fri, 18 Mar 2022 13:58:41 -0700 (PDT) MIME-Version: 1.0 From: Erwin Brandstetter Date: Fri, 18 Mar 2022 21:58:15 +0100 Message-ID: Subject: count() counts ROW values that are NULL To: pgsql-docs Content-Type: multipart/alternative; boundary="0000000000005d729105da846911" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005d729105da846911 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable https://www.postgresql.org/docs/current/functions-aggregate.html#FUNCTIONS-= AGGREGATE-TABLE The manual says: count ( "any" ) =E2=86=92 bigint > > Computes the number of input rows in which the input value is not null. > But ROW values or composite types that "are null" are counted, anyway. See: *db<>fiddle [here]( https://dbfiddle.uk/?rdbms=3Dpostgres_14&fiddle=3D7364f3f582322ac687b39c677= 826a074)* Feels like a bug, but I cannot imagine how this would have slipped everybody's attention for so long. It should at least be documented. Maybe: Computes the number of input rows in which the input value is not a plain NULL value. (Composite or ROW values count in any case - even if value IS NULL evaluates to true.) Regards Erwin --0000000000005d729105da846911 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The manual says:

= count ( &q= uot;any" ) =E2=86=92 bigint

Computes the number of input rows in which the input value is n= ot null.


But ROW values or composite types that "are null" a= re counted, anyway. See:


Feels = like a bug, but I cannot imagine how this would have slipped everybody'= s attention for so long. It should at least be documented. Maybe:
=

Computes the number of input rows in which the input va= lue is not a plain NULL value. (Composite or ROW values count in any case -= even if value IS NULL evaluat= es to true.)

Regards
Erwin
--0000000000005d729105da846911--