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 1pxDb0-0001fa-Gb for pgsql-general@arkaria.postgresql.org; Thu, 11 May 2023 21:13:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pxDaz-0007gQ-9j for pgsql-general@arkaria.postgresql.org; Thu, 11 May 2023 21:13:05 +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 1pxDay-0007gH-Uo for pgsql-general@lists.postgresql.org; Thu, 11 May 2023 21:13:04 +0000 Received: from mail-yb1-xb32.google.com ([2607:f8b0:4864:20::b32]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pxDav-0023Kg-Tz for pgsql-general@lists.postgresql.org; Thu, 11 May 2023 21:13:04 +0000 Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-ba5ebdc4156so4838073276.3 for ; Thu, 11 May 2023 14:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683839580; x=1686431580; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=sbOPscguaZOu7Svj9ykQ0tOjMOuyCRUsNEy6VaMpfQk=; b=MqIIdlzv8PwvvbIZeIX7QIpfa03deKXWzFeOTLAsVVt/V2St5KTw2GDaV0l7kaTCMI MylTiJLIgWjCVap7gth86IpxImR7lqWIwboVwbSbpd6E5dkIfYTTSig2oWdRl8RB5Rt9 GcUS/nciZ0J9PIcf/a1d1WfMJmuRM9idALhCPaLpm4Rw6spVrWInr4IwrszLjCqLVESJ tRTCgrXsWIZzEu1v+MdiMqS6IrzOUVsIFMdp2hu4D26ag2GgRKI1Ae8nR1XYeIXdpEBC hoAMbKXlXN3hF8cTi6lw0Ry7McMO0GHmbxsbFMNYjRMoZtDdpYfqbvzPJqBKu45WMSXP TtVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683839580; x=1686431580; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=sbOPscguaZOu7Svj9ykQ0tOjMOuyCRUsNEy6VaMpfQk=; b=WFSWpuMxH/JAFwHqJcGQX2iQcBd+tHsMrRIV5BdpTGEkF08Lhyig0bUfFfauVsT7YS 9BEHgR6Y1WlwCW5Asnmn8XNYNh7nmCgKh0tcDwRfoOweLFTs9xMnC1hEVu9BqsNVOKis d/oqDix7ZG5YM8yPkj7IAlDDzXQ3M3P71LIE81qNwQO+8rOYXTQ7SHRvTYZsqyNtWhjw NrtxRjUZtVLlNXkJ0NGMDyA+kTqxHY0ndFVVJxuQ6PEvVl+H5dLqcY8OoANhPAqyUnre 25WmqUu+KlH53nXKQA/j49pD42GfqGhW5V0N0xFk7mOobDIYVztHxsHtJ4CL+azpNQwd JglQ== X-Gm-Message-State: AC+VfDy/toXXvelgMpsSZqil/A4fyEUL8EK3vvuPUDXDo5PcgU2j59ZX cZ4cXLY+mWweyNerR3CmuNGhMYVfkfo= X-Google-Smtp-Source: ACHHUZ7KGTPq8rx9HxR0DouiIIRPsFe2gdsQC0xOEKG39mKuUhSzbQ16P7A6Lfh7B9ZD9TXX7BXVlg== X-Received: by 2002:a25:2412:0:b0:b9d:bede:2366 with SMTP id k18-20020a252412000000b00b9dbede2366mr22607459ybk.20.1683839580332; Thu, 11 May 2023 14:13:00 -0700 (PDT) Received: from ?IPV6:2600:1700:bd2c:b810:2cdc:7b7a:1a0:3910? ([2600:1700:bd2c:b810:2cdc:7b7a:1a0:3910]) by smtp.googlemail.com with ESMTPSA id p78-20020a25d851000000b00b9a63c60fefsm4692014ybg.31.2023.05.11.14.12.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 May 2023 14:13:00 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------NJNUuB8mOrZGHauyj7ClW5mQ" Message-ID: <4c0e1dd6-37a1-9712-e7af-0406fab32d72@gmail.com> Date: Thu, 11 May 2023 16:12:59 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: order by Content-Language: en-US To: pgsql-general@lists.postgresql.org References: From: Ron In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------NJNUuB8mOrZGHauyj7ClW5mQ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 5/11/23 09:29, Marc Millas wrote: > Hi, > > I keep on investigating on the "death postgres" subject > but open a new thread as I don't know if it's related to my pb. > > I have 2 different clusters, on 2 different machines, one is prod, the > second test. > Same data volumes. > > On prod if I do > select col_a, count(col_a) from table_a group by col_a order by col_a desc, > I get the numbers of NULL on top. > To get the number of NULL on top on the test db, I have to > select col_a, count(col_a) from table_a group by col_a order by col_a asc. This doesn't answer your question, but: ORDER BY has NULLS { FIRST | LAST } options, so no need to completely change the sort order. And this just confuses your question: https://www.postgresql.org/docs/15/sql-select.html > If|NULLS LAST|is specified, null values sort after all non-null values; > if|NULLS FIRST|is specified, null values sort before all non-null values. > If neither is specified, the default behavior is*|NULLS > LAST|**when**|ASC|****is specified *or implied, and*|NULLS > FIRST|**when**|DESC|****is specified* (thus, the default is to act as > though nulls are larger than non-nulls). -- Born in Arizona, moved to Babylonia. --------------NJNUuB8mOrZGHauyj7ClW5mQ Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit On 5/11/23 09:29, Marc Millas wrote:
Hi,

I keep on investigating on the "death postgres" subject
but open a new thread as I don't know if it's related to my pb.

I have 2 different clusters, on 2 different machines, one is prod, the second test.
Same data volumes.

On prod if I do  
select col_a, count(col_a) from table_a group by col_a order by col_a desc, 
I get the numbers of NULL on top.
To get the number of NULL on top on the test db, I have to 
select col_a, count(col_a) from table_a group by col_a order by col_a asc.

This doesn't answer your question, but: ORDER BY has NULLS { FIRST | LAST } options, so no need to completely change the sort order.

And this just confuses your question:
https://www.postgresql.org/docs/15/sql-select.html

If NULLS LAST is specified, null values sort after all non-null values; if NULLS FIRST is specified, null values sort before all non-null values. If neither is specified, the default behavior is NULLS LAST when ASC is specified or implied, and NULLS FIRST when DESC is specified (thus, the default is to act as though nulls are larger than non-nulls). 


--
Born in Arizona, moved to Babylonia.
--------------NJNUuB8mOrZGHauyj7ClW5mQ--